Powershell – Check your Windows Service Pack level

Powershell

After July 13th 2010, Windows XP SP2 and Vista RTM will no longer be supported by Microsoft.  This means making sure your systems are at LEAST running Windows XP SP3 or Vista SP1.

But for you the ITPro, you need to quickly and EASILY know which machines need the update.

And for this, Powershell is your friend and greatest ally.

All you have to execute is a simple WMI Commandlet

 

GET-WMIOBJECT win32-operatingsystem

 

This ONE little Commandlet will tell us almost ANYTHING we need to know about that version of Windows on a computer.  SKU, LicenseKey and more importantly Name and Service Pack of the software.   Again piping this through a GET-MEMBER will tell us what properties are there.  There are Three we are interested in

NAME
ServicePackMajorVersion
ServicePackMinorVersion

So if you select those objects like so

GET-WMIOBJECT win32-operatingsystem | SELECT-OBJECT Name,ServicePackMajorVersion,ServicePackMinorVersion

You’ll have the details for your local computer.   Now if you execute that with the parameter computername and the name of a remote Workstation (presuming WMI is enabled)

GET-WMIOBJECT win32-operatingsystem –computername SOMECOMPUTEROVERTHERE | SELECT-OBJECT Name,ServicePackMajorVersion,ServicePackMinorVersion

You can pull up the details remotely for any computer.   And now if you have a LIST of computers ready (Let’s try a list from Active Directory, pulled from Quest)

GET-QADCOMPUTER | foreach ( GET-WMIOBJECT win32-operatingsystem –computername $-.Name | SELECT-OBJECT Name,ServicePackMajorVersion,ServicePackMinorVersion )

Now all your work is done.  You can easily determine which machines need the Service Pack or in some cases, need to be upgraded to a newer O/S!

 

All thanks to a free utility called Powershell, and my closest friend 🙂

Sean
The Energized Tech

Leave a Reply