How to use PowerShell to start ConfigMgr updates in current branch

less than 1 minute read

I’m one of those people who rebuilds their test lab often. I like to tinker with WMI and all sorts of other things, so I rebuild to wipe all my configuration changes and start fresh. Current Branch has put a wrinkle in this because I could never start the updates automatically with my build script. Well, I’ve figured out how to start the SCCM updates with a script!

$ParamHash = @{
    NameSpace = 'root\sms\site_ps1'
    Query = 'Select * from SMS_CM_UpdatePackages where Name like "Configuration Manager 1602 Hotfix (KB3174008)"'
}
$Update = Get-WmiObject @ParamHash
$Update.UpdatePrereqAndStateFlags(0,2)

The above code will start the KB3174008 update:

image

You can now use the above code in your scripts to start the updates! I’ll be working on my SCCM build script and will find a good way to wait for updates to arrive and then install them. Once that’s complete, I’ll post it here!

Leave a Comment