Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET
Windows Client OS

Find Service Pack Information

Overview

The one constant about Windows operating systems is that there is always an update. Major updates are delivered as service packs. In fact, some people won’t even upgrade to a new operating system until the first service pack has been released. For the rest of us, and those of you who wait until SP1, you probably need a way to get a handle on what OS service packs you have installed. Assuming you don’t have some sort of system or enterprise management solution in place, you can gather this information yourself pretty easily.



Service pack information is stored in WMI as part of the Win32_OperatingSystem class. So to find out what service pack a particular computer is running, all you need to do is query WMI, and this doesn’t have to require complex scripting. When you query WMI, you will get an instance back of the Win32_OperatingSystem class. The properties we are most interested in are ServicePackMajorVersion and ServicePackMinorVersion, although I can’t think of an incremental OS service pack. The other useful property is CSDVersion, which displays service pack information in a “friendly” format. First, let me show you how to gather this information using the command line tool, WMIC.EXE.

​C:\>wmic os get servicepackmajorversion,csdversion
CSDVersion      ServicePackMajorVersion
Service Pack 1  1

This command queried the local computer for the 2 properties. Querying a few remote machines isn’t much more work.

​C:\>wmic /node:quark,'jdhit-dc01' os get servicepackmajorversion,csdversion,csname,caption /format:list


Caption=Microsoft Windows 7 Professional
CSDVersion=Service Pack 1
CSName=QUARK
ServicePackMajorVersion=1


Caption=Microsoft(R) Windows(R) Server 2003, Enterprise Edition
CSDVersion=Service Pack 2
CSName=JDHIT-DC01
ServicePackMajorVersion=2

I included a few other properties so I could see the computername and the operating system. One quick tip: when the computername has a dash, enclose it in quotes as I had to do. I don’t want to turn this into a WMIC lesson, but as I hope you can see, it is pretty easy to use and discover what service pack is installed.

Using Windows PowerShell is just as easy. The WMI class and property names are the same.

Sponsored Content

Say Goodbye to Traditional PC Lifecycle Management

Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.

​PS C:\> Get-WmiObject win32_operatingsystem -comp "jdhit-dc01","quark" | Select CSName,ServicePackMajorVersion,Caption | format-list


CSName                  : JDHIT-DC01
ServicePackMajorVersion : 2
Caption                 : Microsoft(R) Windows(R) Server 2003, Enterprise 
                          Edition

CSName                  : QUARK
ServicePackMajorVersion : 1
Caption                 : Microsoft Windows 7 Professional

It doesn’t take much more effort to query hundreds of computers to find those that are not up to date. In fact, I wrote a PowerShell function called Test-ServicePack that you can download from the site. By default, this function will test a computer and see if its installed service pack is at least a specific version.

​PS C:\> test-servicepack "jdhit-dc01" -Version 2
True

To see more information use the –Detail parameter.

​PS C:\> test-servicepack "jdhit-dc01" -Version 2 -Detail


Computername            : JDHIT-DC01
OperatingSystem         : Microsoft(R) Windows(R) Server 2003, Enterprise 
                          Edition
ServicePackMajorVersion : 2
ServicePack             : Service Pack 2
OK                      : True

The function tests if the service pack is at least a certain version. My domain controller is at SP 2, but checking for SP1 will return True.

​>PS C:\> test-servicepack "jdhit-dc01" -Version 1
True

To test for an exact version use the –Exact parameter.

​PS C:\> test-servicepack "jdhit-dc01" -Version 2 -Exact
True
PS C:\> test-servicepack "jdhit-dc01" -Version 3 -Exact
False

To put this in a larger perspective, let’s say Microsoft releases a new service pack and you need a list of computers that will need it. Using a text file of your servers, it is as easy as this:

​PS C:\> get-content computers.txt | test-servicepack -version 2 -detail -exact| Where {!$_.OK} | Select Computername,ServicePackMajorVersion | Out-file c:\work\NeedSP2.txt

I also could have searched for version 1 only.

Conclusion

Finding what OS service packs you have installed isn’t difficult. Service pack information is not hidden away, you just need to know where to look.

Related Topics:

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: