PowerShell Tip of the Week: Get SCCM client version remotely

In Todays tip you will find out how to check SCCM client version. To get this information we will use Get-WMIObject command.

SCCM client version

Information about SCCM client version is located under SMS_Client class in root\ccm namespace:

# Locally
Get-WMIObject -Namespace root\ccm -Class SMS_Client
(Get-WMIObject -Namespace root\ccm -Class SMS_Client).ClientVersion

# Remotely
(Get-WMIObject -ComputerName DC01 -Namespace root\ccm -Class SMS_Client).ClientVersion
SCCM Client check
SCCM Client check

You can also check SCCM client version remotely on servers from txt file list:

Get-Content -path C:\users\$env:username\desktop\Servers.txt | foreach { "{0} - {1}" -f $_, (Get-WMIObject -ComputerName $_ -Namespace root\ccm -Class SMS_Client).ClientVersion}
DCs
DCs

To make the output look better we can use the following script.

SCCM Client
SCCM Client

    $Servers = Get-Content -path "C:\users\$env:usename\desktop\Servers.txt"
    $Array = @()

    ForEach($Server in $Servers)
    {
        If((Test-Path \\$Server\c$) -match "False")
        {
            Write-Warning "Failed to connect to $Server"
        }
        Else
        {
            $SCCMClient = $null
            $Object = $null

            $SCCMClient = (Get-WMIObject -ComputerName $Server -Namespace root\ccm -Class sms_client).ClientVersion

            If($SCCMClient -ne $null)
            {
                $Object = New-Object PSObject -Property ([ordered]@{ 
  
                    Server                = $Server
                    "SCCM Client Version"  = $SCCMClient    
                     
                })
            
                # Add object to our array
                $Array += $Object
            }
            Else
            {
                $Object = New-Object PSObject -Property ([ordered]@{ 
  
                    Server                = $Server
                    "SCCM Client Version"  = "(Null)"   
                     
                })
            
                # Add object to our array
                $Array += $Object
            }
        }                   
    }

    If($Array)
    {
        Return $Array
    }

Leave a Reply

Your email address will not be published. Required fields are marked *