# windows-update-pending.ps1 — count of pending Windows updates. $Url = "YOUR_URL/wsus" $Session = New-Object -ComObject "Microsoft.Update.Session" $Searcher = $Session.CreateUpdateSearcher() try { $Pending = ($Searcher.Search("IsInstalled=0 and Type='Software'")).Updates.Count $Reboot = ((New-Object -ComObject "Microsoft.Update.SystemInfo").RebootRequired) -as [bool] } catch { $Pending = -1 $Reboot = $false } $Body = (@{ hostname = $env:COMPUTERNAME pending_count = $Pending reboot_required = $Reboot }) | ConvertTo-Json -Compress Invoke-RestMethod -Uri $Url -Method Post -Body $Body ` -ContentType "application/json" -TimeoutSec 15 | Out-Null