cmdlets to Check SCCM status from client OS (windows 7)

This topic contains 5 replies, has 5 voices, and was last updated by  liam 1 month, 1 week ago.

  • Author
  • #25819


    I'm New to powershell and is very much interested in it.
    I Couldn't get a cmdlet to check SCCM client status from client (windows 7/8.1).

    Kindly Help on it.

    Thanks in Advance...

  • #25821

    Tim Pringle

    Hey kvprasoon,

    Cmdlets for SCCM are really on the server side. Can you give a bit more detail on what you want to validate? The SCCM client is a big beast as far as logfiles goes.

    If you just want to check to ensure the service is running, you could do this :

    Get-Service -Name 'sms agent host'  | Select-Object -Property Status

    This will return the status to you, letting you know if the service is stopped or running.

    • #25822


      Hi Tim,
      . Thanks for your immediate response,
      . I am writing a script to check the sccm status for a bunch of machines which are not reflecting in console.
      And to troubleshoot as per SOP.
      It would be helpful if there any option using WMI....too

    • #95724


      Sorry about late response, but I'm trying to check the SCCM service status, and write the hostname to CSV, if the service is NOT running.
      This part Ive used befire: Get-Service -Name 'sms agent host' | Select-Object -Property Status
      Has anyone done anything like this?

  • #25823

    Jack Neff

    I've spent a significant amount of my life troubleshooting SCCM client health and it's an ever ongoing journey. The problem with using WMI to check CCM client health is that often times the client is failing BECAUSE WMI is broken or corrupt. For this reason (and many others believe me) I've found that it's just easier to do a full rip on that puppy because you can spend days in the rabbit hole figuring out why client 1 of 350 isn't working and once you solve it you think you have a golden ticket which immediately gets ditched when you find that fix doesn't work on 2 of 350.

    SCCM comes with some neat tools to fix client issues (ccmsetup.exe, ccmrepair.exe, ccmclean.exe) but I have found them to be unreliable so I scripted my own. I removed the fluff so this is basically the meat and potatoes.

    #Stop and remove ccm service
    & sc stop ccmsetup
    & sc delete ccmsetup
    #Remove ccm certs
    Remove-Item 'HKLM:\SOFTWARE\Microsoft\SystemCertificates\SMS\Certificates\*' -Force
    #Remove ccm files
    Remove-Item -Path $env:windir\ccm -Recurse -Force
    Remove-Item -Path $env:windir\system32\ccm -Recurse -Force
    Remove-Item -Path $env:windir\ccmcache -Recurse -Force
    Remove-Item -Path $env:windir\ccmsetup -Recurse -Force
    Remove-Item -Path $env:windir\system32\ccmsetup -Recurse -Force
    Remove-Item -Path $env:windir\smscfg.ini -Force
    Remove-Item -Path $env:windir\sms*.mif -Force
    #Remove ccm registry keys
    $RegRoot = "HKLM:\Software\Microsoft"
    Remove-Item -Path "$RegRoot\ccm" -Recurse -Force
    Remove-Item -Path "$RegRoot\ccmsetup" -Recurse -Force
    Remove-Item -Path "$RegRoot\sms" -Recurse -Force
    #Remove ccm wmi namespaces
    Get-WmiObject -Query "SELECT * FROM __Namespace WHERE Name='CCM'" -Namespace "root" | Remove-WmiObject
    Get-WmiObject -Query "SELECT * FROM __Namespace WHERE Name='SMS'" -Namespace "root\cimv2" | Remove-WmiObject
    #Repair WMI 
    $Path = 'C:\Windows\System32\wbem'
    Stop-Service -Name Winmgmt -Force 
    Remove-Item "$Path\repository" -Recurse -Force
    & wmiprvse /regserver
    Start-Service -Name Winmgmt
    Get-ChildItem $Path -Filter *.dll | ForEach-Object { & regsvr32.exe /s $_.FullName } | Out-Null
    Get-ChildItem $Path -Filter *.mof | ForEach-Object { & mofcomp.exe $_.FullName } | Out-Null
    Get-ChildItem $Path -Filter *.mfl | ForEach-Object { & mofcomp.exe $_.FullName } | Out-Null
    & mofcomp.exe 'C:\Program Files\Microsoft Policy Platform\ExtendedStatus.mof' | Out-Null

    This will completely remove the ccm client and perform a wmi repair leaving the machine ready for a fresh install of sccm client (no reboot required). You can remotely execute this against machines with Invoke-Command with a user logged in and they won't know anything is happening. After the clients are removed try another client push from ConfMgr and hopefully it sticks. If that doesn't work, I usually re-image.

    Good luck!

  • #56026

    Krishna Santosh M

    Hello Jack,

    The above powershell script would be really helpful. However, do you have any VB / Batch script files which does the same things the powershell script does? I'm familiar with these scripting to a little extent and have created few batch files which perform a couple of actions only.

    My reason regarding batch file explicitly is because we need to have windows Remote management service started on the end user machines to run powershell scripts as per my understanding. Our environment has Windows server 2003 which cannot work as expected to process powershell scipts.

    Could you also let me know what would be the commands to run this powershell script on multiple machines if we have the machine names in a list.

You must be logged in to reply to this topic.