Use this Powershell script to get details about a Windows host for reproduction

When i worked for a digital agency and started new web development projects all the time it was not uncommon to inherit a website’s existing architecture and servers with no documentation or previous team members to reference. I also think its very unwise to agree to service an SLA for an environment you didn’t build yourself or from automation that can be referenced. Here is a list of Powershell commands i frequently used to identify what has been done to a windows server before i create a fresh installation for build testing.

Further as i was not always given access to the hosts themselves i frequently provided the commands in the form of a script with a txt output file i could be delivered by an administrator.

https://github.com/schoonercg/nrprofiler

The contents of the script collect the following information and follows.

Hostname, IP Addresses, Windows Version, Windows Features Installed, Installed Windows Updates, Installed Applications, IIS Apps, IIS Sites, IIS AppPools, Users, Administrators, Running Services, Firewall Rules

Netrun Profiler – nrprofile.ps1

echo “Hostname:” > c:\NRprofile.txt

hostname >> c:\NRprofile.txt

echo “IP information:” >> c:\NRprofile.txt

cmd /c ipconfig /all >> c:\NRprofile.txt

echo “Windows Version:” >> c:\NRprofile.txt

(Get-WmiObject -class Win32_OperatingSystem).Caption >> c:\NRprofile.txt

echo “Features Installed” >> c:\NRprofile.txt

Import-module servermanager ; Get-WindowsFeature | where-object {$_.Installed -eq $True} | format-list DisplayName >> c:\NRprofile.txt

echo “Installed Updates” >> c:\NRprofile.txt

Get-HotFix >> c:\NRprofile.txt

echo “Installed applications” >> c:\NRprofile.txt

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table -AutoSize >> c:\NRprofile.txt

echo “IIS Apps:” >> c:\NRprofile.txt

cmd /c %systemroot%\system32\inetsrv\APPCMD list app >> c:\NRprofile.txt

echo “IIS Sites:” >> c:\NRprofile.txt

cmd /c %systemroot%\system32\inetsrv\APPCMD list site >> c:\NRprofile.txt

echo “IIS AppPools:” >> c:\NRprofile.txt

cmd /c %systemroot%\system32\inetsrv\APPCMD list apppool >> c:\NRprofile.txt

echo “Users and Administrators” >> c:\NRprofile.txt

net user >> c:\NRprofile.txt

net localgroup >> c:\NRprofile.txt

net localgroup Administrators >> c:\NRprofile.txt

echo “Running Services” >> c:\NRprofile.txt

net start >> c:\NRprofile.txt

echo “Firewall Rules” >> c:\NRprofile.txt

netsh advfirewall firewall show rule name=all >> c:\NRprofile.txt

echo “END” >> c:\NRprofile.txt

Preparing for Disaster Recovery Pt 1.

Disaster Recovery and Business Continuity or DRBC is traditionally a complete reproduction of a production environment in a different geographical location for the purpose of continuing business in the event of a disaster. The process used to mean preparing the hardware and applications needed in advance, at great cost, though in the modern age of Cloud based architectures and Devops tools for provisioning automation we can create the tools to provision a production environment dynamically reducing the overall cost of having a full DRBC plan in place. 

If you haven’t taken the time to document your disaster recovery plan in detail before taking your environment live then if and when the need arises you’ll find that the reactive plan is a difficult and complicated process. Think of your disaster recovery plan as the total timeline to bring your services back online with no dependencies. If you’ve already built your production environment you must ask yourself “how quickly can i do this again?” and “is there anything i can do to speed up the process?”

I will typically detail the manual steps for building the entire project out for documentation purposes resulting in a linear list of steps we can then seek to automate, both reducing our build time and susceptibility to error. In this example website application i like to address the following requirements for each environment 

Regions

What hosting regions are in use for this site? Is this site a multi-region architecture?

Domains and sub-domains in use

What are the domains assigned by default?

What are the custom domains assigned to this site?

What are the custom sub-domains assigned to micro-sites?”

SSL Certificates required

Is https in use? required?

Is an SSL certificate installed? if yes, what domains?”

Number of public ips needed

How many Public IP’s are needed for this architecture?

vnet size

How large of a network do we need to create? App services do not require vnets

subnet_X size

How large must the network be? 

DNS Transaction

query custom domains for resolution

TTL (timing effects total queries and ability to update) TTL 1 Day or 1 Hour, 5 mins for migrations but left this way will consume all queries. 

total queries Total queries may not be available but we can try to identify the DNS provider and compare to known defaults.

response time DNS response time can indicate a throttled or maxed concurrent capacity DNS lookup.

Endpoints (firewall/loadbalancer/ipwhitelisting)

Identify exposed services – HTTP, HTTPS, FTP, Webdeploy, ssh

Firwall Rules

Identify any open ports – common services are 80, 443, 21, 8175, 22

Loadbalancing Rules

If we have multiple nodes, is the load being distributed? Can we identify the LB Logic?

ip restrictions / whitelisting

Are IP restricted zones responding restricted?

SSL decoding

Is SSL certificate installed to the app services or load balancer?

Network

 What are the Application IP’s, Database IPs, other Services IPs

 vnets or NSGs (ip ranges)

subnets

Security groups

Verify NSG’s or ACL’s reflect the firewall rules and IP restrictions identified.

Application

Check for known application pages

config files, connection strings,

IIS /webserver

(versions, features, permissions)

.NET /stack

(versions, app pools, permissions)

Deployment Dependencies

(webdeploy / octopus agent / sftp)

Service Dependencies

Database Server

(versions, ports, users, permissions, transaction read/write times)

Search Server

ip, index strategy

NOSQL or other application Database Servers

CDN

(cache control headers, origin urls, cache clearing)

OS

Patch level/ updates

version

installed features

users

Deployment Users

Hypervisor

Is there a hypervisor layer installed on the hardware, is this a cloud based hypervisor?

Performance variation

What is the average performance and the Maximum acceptable outliers?

HA / SLA / clustering

What is the SLA based on the current configuration?

Billing

fixed cost provisioned or incremental range(autoscaling)

Hardware

Server,LB,Firewall or cloud service instance sizing

Dedicated solutions

Datacenter details

Cloud Generations

(AWS sizing / Azure Series Letter) Can we identify the sizing for the instances?

Disaster Recovery

Azure ARM or AWS Cloud Formation templates for provisioning allow rapid environment rebuilds

Webserver scaling

Recommended scaling method 

Database Mirroring or replication (service recovery)

Mirror or Paas replication?

Database offsite logshipping (data recovery)

database offsite logshipping, geo replication, backup exports 

Update your Sitecore License (or any other single file) on Azure Paas with this Script

As a license expires it can suddenly be a daunting task to replace the license.xml file on each web application for each environment in your Sitecore install. I found a great StackOverflow post about publishing a single file where one of the comments (not the accepted answer) provided a script you can use to obtain the publishing credentials and then upload a single file.

The script deploys a source folder to a target destination so I used a folder with only the license.xml as my source argument and /site/wwwroot/App_Data/ as my destination. This allowed me to update the license file on 3 environments with 4 webapps each in about 12 seconds.

.\DeployFolder.ps1 -websiteName Sitetest-cm -resourceGroupName SitetestGroup -sourceDir C:\scmc\DeployFolder -destinationPath “/site/wwwroot/App_Data”

DeployFolder.ps1

Thanks to the stackoverflow user Lewis Roberts for sharing and crediting original author. https://stackoverflow.com/questions/37787686/upload-publish-webapp-files-to-azure-via-powershell