SCCM SCRIPT TO INVOKE SCCM SOFTWARE UPDATE REMOTELY

In this post we will learn how to use SCCM SCRIPT option for triggering software updates remotely

Installing software updates is mandatory for most of the customers for security. While we deploy software updates, some of the clients will be in enforcement state unknown or non compliance

Using SCRIPT option in sccm, we can trigger the software updates remotely. Here will use Powershell script to trigger the installation. This script will check if any updates are available in software Center but failed or maintenance window or could be other reason. Then script will trigger the installation

How To Do?

For creating script Navigate to

Software Library->Overview->Script. Right click on Script and Create Script

  • SCRIPT NAME – COMPLIANCE IMPROVEMENT
  • SCRIPT LANGUAGE- POWERSHELL

Paste below script in Script Window

$MissingUpdates = Get-WmiObject -Class CCM_SoftwareUpdate -Filter ComplianceState=0 -Namespace root\CCM\ClientSDK$MissingUpdatesReformatted = @($MissingUpdates | ForEach-Object {if($_.ComplianceState -eq 0){[WMI]$_.__PATH}})if ( $MissingUpdatesReformatted){$InstallReturn = Invoke-WmiMethod -ComputerName $env:computername -Class CCM_SoftwareUpdatesManager -Name InstallUpdates -ArgumentList (,$MissingUpdatesReformatted) -Namespace root\ccm\clientsdkwrite-host "Updates found, initiated"}else{write-host "No updates found"}

Click next to complete Script wizard

Post completing wizard we need to Approve the script. Navigate to

Software Library->Overview->Script. Right click on your script and approve.

Note – If approving option is grayed out. Follow below steps

Administration->Site configuration->Sites. Select Hierarchy setting and uncheck Script author s require additional script approve

How To Execute

For executing the scripting , right click on the client and click on Run Script

Above snap shows missing updates found in software Center.

As checked in Updatedeployment.log, updates are installing

1 thought on “SCCM SCRIPT TO INVOKE SCCM SOFTWARE UPDATE REMOTELY”

Leave a Comment