Created: 8-20-21

Updated: 8-20-21

This neat little script can run on a desktop and it will fetch updates from your WSUS server, install them and then automatically reboot. If said desktop also has pending updates it will reboot after 10 minutes, enjoy:

Install-Module PSWindowsUpdate -force
Import-Module PSWindowsUpdate -force

# Start WSUS updates, if no updates, just restart
$updates = Get-wulist -verbose
$updatenumber = ($updates.kb).count
if ($updates -ne $null) {Install-WindowsUpdate -AcceptAll -Install -AutoReboot | Out-File “c:\logs\pswu\$(get-date -f yyyy-MM-dd)-WindowsUpdate.log” -force} else {shutdown -r -t 600}