Greetings!
I have had occasions where I wanted to inventory all my servers and what version of Windows Server is running on those servers. Larger companies can use System Center Operations Manager (SCOM) to get that information. However System Center can be expensive and overkill for small to medium businesses.
In order to get the list I wanted, I used the following PowerShell script:
Import-Module ActiveDirectory
Get-ADComputer -Filter * -Properties OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion | Where-Object {$_.OperatingSystem -like '*server*'} |
Select-Object -Property Name, OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion
It is important to include the Import-Module command. If the command is missing the Get-ADComputer command will not work and you will get an error.
The output from the script will look like the following:
Name OperatingSystem OperatingSystemServicePack OperatingSystemVersion
----- --------------- -------------------------- ----------------------
Server1 Windows Server 2008 R2 Enterprise Service Pack 1 6.1 (7601)
Server2 Windows Server 2008 R2 Enterprise Service Pack 1 6.1 (7601)
Server3 Windows Server 2008 R2 Enterprise Service Pack 1 6.1 (7601)
This script displays the ease of using Powershell. By using just a couple commands, you can pull the information you want.
I hope you find this script helpful. Good luck and happy scripting.
Mike
No comments:
Post a Comment