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

Leave a Reply

Your email address will not be published.