Install Windows Updates from CMD

Below are a few one liners you can use to install Windows updates from the command line

This one can be straight from Run

C:\Windows\System32\cscript.exe C:\Windows\System32\en-US\WUA_SearchDownloadInstall.vbs

A powershell option would be as below

Install-Module PSWindowsUpdate


Install-WindowsUpdate -install -acceptall

To reboot the server/machine at a given time via CMD you can use the below which will reboot the device at 3AM the following morning.

$StartDate=(GET-DATE); $EndDate=(Get-Date -Hour 3 -Minute 00 -Second 00).AddDays(+1); shutdown /r /t ([math]::ceiling((New-Timespan -Start $StartDate -End $EndDate).TotalSeconds))

Or to reboot at 11:30 that evening run, the difference being the .AddDays(+1)

$StartDate=(GET-DATE); $EndDate=(Get-Date -Hour 23 -Minute 30 -Second 00); shutdown /r /t ([math]::ceiling((New-Timespan -Start $StartDate -End $EndDate).TotalSeconds))

If you found this article helpful, would you consider buying me a Coffee?