Find servers that don't have SCCM installed

This topic contains 8 replies, has 4 voices, and was last updated by  cm 3 months ago.

  • Author
    Posts
  • #78889

    cm
    Participant

    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

  • #78892

    Ivan
    Participant

    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.

    • #78893

      cm
      Participant

      Ivan,

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

    • #78899

      Olaf Soyk
      Participant

      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. 😉

    • #78902

      cm
      Participant

      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.

  • #78896

    Ivan
    Participant

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

    That's quick and dirty fix.

  • #78916

    Will Anderson
    Keymaster
    Try {
    
        Get-WmiObject -ComputerName $Computer -Namespace root\CCM -Class SMS_Client -ErrorVariable SMSError
    }
    Catch [System.Exception]{
    
        Write-Output ($Computer + ' returned error ' + $SMSError)
    
    }
  • #78940

    Will Anderson
    Keymaster

    Now that I'm not rushing to beat a dying laptop battery, I can elaborate. ^_^

    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.

    • #79157

      cm
      Participant

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

You must be logged in to reply to this topic.