CI – Get-ServicePackMajorVersion

Recently I got and a mission to inventory the ServicepackMajorversion on our servers. So ive made a script that you can use in a CI if you want.

Discovery Script

   Read what ServicePackMajorVersion you have on your machine
   Check if computer have Servicepack 1 installed or not.
   Written by Pontus Wendt
function Get-ServicePackMajorVersion
    param ()

    Try {

# Get Operating System Info
$sOS =Get-WmiObject -class Win32_OperatingSystem -computername Localhost

foreach($sProperty in $sOS)
        ForEach-Object { 
            If($sProperty.ServicePackMajorVersion -match "0") { 
                $State = 0} 
            ElseIf($sProperty.ServicePackMajorVersion -match "1") {
                $State = 1} 
   catch {
   # Error hantering


Compliance Rule
Equals 1 ( which is “a Service pack is installed”)

Good luck!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s