Question in short
How to automate with Windows built-ins (batch/PowerShell) or freely available tools, prefereably command-line, following steps:
- Scan for all currently available updates on WU
- Download and install them right now (i.e. without any throttling/scheduling/backgrounding)
- Restart if necessary, closing whatever doesn't closes automatically.
I'd also like something that triggers the same background mechanism behind existing WU in Setting panel, not something that will use separate infrastructure by setting up its own download locations or whatever.
Background
I have a PC that doesn't have regular restarts or fixed working schedule. WU is running, but all its auto-restart facilities are completely disabled so it won't get in the way of the work at some absolutely inconvenient time. Sometimes a window of opportunity comes up when I can dedicate time to running a full cycle of updates. To do it manually I need to:
- Open WU settings
- Run "Check for updates" to reveal fresh updates missing for any reason
- Click "Download" and then wait arbitrary long time, because apparently this only schedules actual download and both download and installation are heavily throttled depending on PC load
- Wait until process is done and manually restart PC if necessary - trying to use "Update & Restart" from power menu often only installs already downloaded stuff and skips over what is not downloaded
- Restart often reveals previously hidden updates that DO NOT depend on what was just installed - Settings' WU panel just seems to stop displaying new updates after at least one freshly installed requests restart
I'd like to automate all those steps and, if possible, reduce number of restarts.
So far I tried
PSWindowsUpdate
3rd party module for PowerShell, but it seems to display different set of available updates - e.g. it offered me to install Silverlight - and whatever it installs does not appear in "View update history" list.
usoclient.exe
looks promising, but there's no official documentation for it and from some online examples of people cobbling up some working scripts, it seems there's no reliable way to detect when all updates are done installing and it is time to reboot.
Dism
Cmdlets andDISM
Command-Line Options