Find servers that don't have SCCM installed

Hi. I have following script which will determine which servers DO have SCCM installed and currently displays to a window inside of PrimalScript. I only want to show those that don’t have it installed.

Code

You should query if the server is ONLINE first, then if SCCM is installed, something like this:

if (Test-Connection -CN $Computer -Count 1 -BufferSize 16 -Quiet) {

    if (Get-Service -Name 'sms agent host') {

        Write-Host "SCCM Agent is installed on " $Server

    }

    Else {
        
        Write-Host "SCCM Agent is not installed on " $Server

    }

}

Note that I haven’t tested this code, it might need a little error management but it should work.

Ivan,

Thank you. What if I only want servers that don’t have it installed to come up?

If you want only the servers without SCCM then comment out line 5.

That’s quick and dirty fix.

Just an idea: You can get the server with SCCM client installed from SCCM - there are SCCM cmdlets for this. So you just have to compare the list of servers from the SCCM with the list of servers from AD or any other list you have available. :wink:

Olaf,

Unfortunately we are on SCCM 2007 and it’s in the (long) process of being upgraded to 2012. We do not get to control SCCM even though we host the servers in our datacenter, unfortunately. We do have 2012 R2 Servers in our environment so until they fully get 2012 SCCM up and running…

… Also, we have a VBScript that does what I wanted to do, but with Windows 10 rolling around soon in our environment, we needed to move to a current scripting language.

Try {

    Get-WmiObject -ComputerName $Computer -Namespace root\CCM -Class SMS_Client -ErrorVariable SMSError
}
Catch [System.Exception]{

    Write-Output ($Computer + ' returned error ' + $SMSError)

}

Now that I’m not rushing to beat a dying laptop battery, I can elaborate. :slight_smile:

You can use Get-WMIObject and target the SMS_Client class in the root\ccm namespace to check the installation of the client. There’s actually a lot of data that you can get out of the class. If the class doesn’t exist, the client is either not installed, or horribly broken.

Hey can you expand further? I tried it out and I got a lot of servers listed I know have SCCM installed.

If it returns something of ($Computer + ’ returned error ’ + $SMSError) in the output, those will be the machines that do not have the agent installed.