San Tran

an IT System Engineer

PowerShell, SCCM

Trigger Software Update Installation in the Software Center

# Get all available and not pending reboot updates
$missingUpdates = Get-WmiObject -Class CCM_SoftwareUpdate -Filter {ComplianceState=0 and EvaluationState!=8} -Namespace root\CCM\ClientSDK

if ($missingUpdates){
    $InstallReturn = Invoke-WmiMethod -ComputerName $env:COMPUTERNAME -Class CCM_SoftwareUpdatesManager -Name InstallUpdates -ArgumentList (,$missingUpdates) -Namespace root\ccm\clientsdk
    if($InstallReturn.ReturnValue -eq 0){
        Write-Host "Updates found, initiated"
    }
    else{
        Write-Host "Updates found, failed to initiated"
    }    
}
else{
    Write-Host "No updates found"
}