CI – Get-ServicePackMajorVersion

Hey!
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


function Get-ServicePackMajorVersion
{
    [CmdletBinding()]
    param ()

    Begin
    {
    }
    Process
    {
    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
   }
   $state

    }
    End
    {
    }
}
Get-ServicePackMajorVersion

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

Good luck!

/Pontus

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s