Use Powershell to trigger Windows updates SCCM client

When SCCM does not show the windows updates this Powershell can be used.

[

code language = "powershell"]

$Server='hostname'

#https://docs.microsoft.com/en-us/archive/blogs/charlesa_us/triggering-configmgr-client-actions-with-wmic-without-pesky-right-click-tools

#Trigger SSCM trigger Schedule 113 - Scan by Update Source 
#
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}"  | Out-Null

Start-Sleep -s 60


#restart windows update service
#
Get-WmiObject Win32_Service -Computer $Server -Filter "Name='wuauserv'" | ForEach-Object {
                    $_.StopService()
                    $_.StartService()
                }|Out-Null

Start-Sleep -s 5


#Trigger SSCM trigger Schedule 108 -  Software Updates Assignments Evaluation Cycle 
#
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000108}"  | Out-Null


#check 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" }

#Install 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


#Trigger SSCM trigger Schedule 113 - Scan by Update Source
#
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000113}"  | Out-Null

Start-Sleep -s 60

#restart windows update service
#
Get-WmiObject Win32_Service -Computer $Server -Filter "Name='wuauserv'" | ForEach-Object {
                    $_.StopService()
                    $_.StartService()
                }|Out-Null

Start-Sleep -s 15


#Trigger SSCM trigger Schedule 108 ( Software Updates Assignments Evaluation Cycle )
#
Invoke-WMIMethod -ComputerName $Server -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000108}"  | Out-Null




[/code]

  • Triggering ConfigMgr client actions with WMIC without pesky right click tools.
  • https://docs.microsoft.com/en-us/archive/blogs/charlesa_us/triggering-configmgr-client-actions-with-wmic-without-pesky-right-click-tools

Leave a Reply

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