Force Software Update Point (SUP) to sync now using PowerShell

When you debug the Software Update Point (SUP) in SCCM one of things you might be doing a lot is synchronizing the SUP. There are many way to achieve that:

  1. You can use the console – Go to ‘Software library -> Software updates‘ simply right click the All software updates  and choose Synchronize Software Updates
  2. Use the Configuration Manager Service Manage – open up the tool, go to your server and browse to the SMS_WSUS_SYNC_MANAGER. Right click the component to query its status and if its not running, right click it again and choose start.
  3. Using the registry – browse to the following path [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\COMPONENTS\SMS_EXECUTIVE\Threads\SMS_WSUS_SYNC_MANAGER] and look at the CurrentState  key value. If its not Running, edit the Requested Operation  key and enter Start.
  4. And finally – using PowerShell. My favorite!

$SiteStats = Get-WmiObject -Query 'select * from sms_providerlocation' -Namespace root\sms

$SiteCode = $SiteStats.SiteCode

$MPName = $SiteStats.PSComputerName

$SUP = [wmiclass]("\\$MPName\root\SMS\Site_$($SiteCode):SMS_SoftwareUpdate")

$SyncNow = $SUP.GetMethodParameters("SyncNow")

$SyncNow.fullsync = $true

$ActionResult = $SUP.SyncNow($SyncNow)

if($ActionResult.ReturnValue -eq 0){Write-Host "Sync started" -ForegroundColor Green}else{Write-Host "Sync cannot start" -ForegroundColor red}

 

Simply by invoking the SyncNow WMI method we start the synchronization phase immediatly! Use the wsyncmgr.log to follow.

Happy synckin 🙂

 

What do you think about this post?