Prerequisites – Must have a WSUS management tools installed on the computer that you are running this script,
[void][reflection.assembly]::LoadWithPartialName(“Microsoft.UpdateServices.Administration“) $updateServer = “WSUS SERVER NAME or IP Address“ $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer,$false) $computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope; $computerScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot; $updateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope; $updateScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot; $computers = $wsus.GetComputerTargets($computerScope); $computers | select FullDomainName,IPaddress | Sort-Object -Property IPaddress $count = $computers | Measure-Object; Write-host ""; write-host "Total number of objects: "$count.count;
Change the $updateServer to you WSUS server name or IP address.