Triggering SCCM Client using Powershell

This post is a part of my series on Patching SQL Server AG using SCCM and Powershell
Please read this post for the complete overview

Sometimes the SCCM client does not show any updates. Nice, nothing we have to do! Unfortunately, this does not mean that there are no updates available! I’ve learned that the SCCM client is VERY sensitive and can get stuck in a “I am just going to do nothing”-state. I also noticed that any WMI query against the SCCM namespace will then run forever. There can be a couple of reasons for this behavior:

  • When you install (or deinstall) patches manually, or any other way outside SCCM, the client gets confused because his “supposed-to-be” -state differs from reality and simply stops working (in my experience).
  • There is a pending reboot
  • If there is a Windows Servicing Stack Update (SSU) available, install this one first as it blocks other updates to appear in the client! There are a bunch of upvotes of this “bug”to get fixed, filed by the SCCM community here

If there is a Servicing Stack update, install this first!

In these cases you want to trigger the client, by telling it to re-scan the catalog and provide the missing updates.
If you prefer (for some reason) to do this manually: From the control panel open de configuration manager. The tab “actions”, shows you a couple of triggers that you can run against the client:

The only way I got the SCCM client to work and show me the pending updates is the following list of steps (I was able to reproduce this!):

  • Trigger SSCM trigger Schedule 113 ( Scan by Update Source )
  • Wait 60 sec
  • Restart Windows Update Service
  • Trigger SSCM trigger Schedule 108 ( Software Updates Assignments Evaluation Cycle )
  • Check for Windows Servicing Stack Update
  • Install Windows Servicing Stack Update (Never requires reboot).
  • Trigger SSCM trigger Schedule 113 (Scan by Update Source)
  • Wait 60 sec
  • Restart Windows Update Service
  • Trigger SSCM trigger Schedule 108 ( Software Updates Assignments Evaluation Cycle )

To trigger an SCCM Schedule using Powershell and WMI:


Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}"  | Out-Null

An extensive list of triggercodes can be found here

To Remote restart the Windows Update Service:


Get-WmiObject Win32_Service -Computer $Server -Filter "Name='wuauserv'" | ForEach-Object {

To determine if there is a pending Windows Servicing Stack Update:


Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_SoftwareUpdate -ComputerName $Server | Where-Object { ($_.EvaluationState -like "*$($AppEvalState0)*" -or $_.EvaluationState -like "*$($AppEvalState1)*") -and $_.Name -match "Servicing Stack Update" }

Installing the Windows Servicing Stack Update:


$PendingUpdateList = (Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_SoftwareUpdate -ComputerName $Server | Where-Object { ($_.EvaluationState -like "*$($AppEvalState0)*" -or $_.EvaluationState -like "*$($AppEvalState1)*") -and $_.Name -match "Servicing Stack Update" })
$MissingUpdatesReformatted = @($PendingUpdateList | ForEach-Object { if ($_.ComplianceState -eq 0) { [WMI]$_.__PATH } }) 

Invoke-WmiMethod -ComputerName $Server -Class CCM_SoftwareUpdatesManager -Name InstallUpdates -ArgumentList (, $MissingUpdatesReformatted) -Namespace root\ccm\clientsdk | Out-Null

I hope my guide on Triggering SCCM Client using Powershell was helpful—feel free to leave questions in the comments!

If the task still seems a bit daunting, book a call with Data Masterminds. We have the expertise to execute this and other SQL Server management and troubleshooting tasks to save you the headache.

One thought to “Triggering SCCM Client using Powershell”

Leave a Reply

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