Force all WSUS clients to check-in and pickup approved updates immediately in PowerShell

Problem:

After approving updates in WSUS and wanting to then install them you have to either wait 24 hours which is the default interval (this can be changed in a GPO) or you can manually run wuauclt.exe /detectnow  and wuauclt.exe /reportnow.  How can we run this on all servers in the domain?

Solution:

This can be done using the following PowerShell script:

# Powershell Script to force clients check into WSUS server

# Import Active Directory PS Modules CMDLETS
Import-Module ActiveDirectory

$comps = Get-ADComputer -Filter {operatingsystem -like "*server*"}

Foreach ($comp in $comps) {

Invoke-Command -computername $comp.Name { wuauclt.exe /detectnow }
Write-Host Forced WSUS Detect on $comp.Name

Invoke-Command -computername $comp.Name { wuauclt.exe /reportnow }
Write-Host Forced WSUS Report-In on $comp.Name

}

Leave a Reply

Your email address will not be published. Required fields are marked *