SCCM - Automatic Deployment Rule Error run Check script

Rate this item
(2 votes)

One of the issues i have come accross when deploying our automatic updates through SCCM in a proxy'd or firewalled environment is that sometimes the WSUS servers timesout. giving us several types of error codes.

In most of my SCCM setups i have setup EOM (end of month) rollouts to which our policies only run once a month. however if it fails then i have to wait another month for this to run leaving 2 months worth of updates to apply next run,  and maybe more if it doesn't run properly the next time.

so i had to think of a way to check the error status of our rules to see if its in error state and if so rerun the rule to apply, and since SCCM doesn't give us the option to rerun on failure then i had to powershell a script together for a nightly check.

Hope this code helps.


$sccmautorule = Get-CMSoftwareUpdateAutoDeploymentRule


foreach ($sccmautorule in $sccmautorule)


if ($sccmautorule.lasterrorcode -eq 0)


write-host "The Auto Rule has run successfully This Equals 0 do not run"





Write-host "The Auto Rule has failed - Running to get success message"

Invoke-CMSoftwareUpdateAutoDeploymentRule -id $sccmautorule.AutoDeploymentID








Read 42821 times Last modified on September 03 2020
Login to post comments