Check if a new Windows version is available and install programmatically

722 views Asked by At

I would like to check programmatically if a new Windows "feature update" - that is a new major version like 1904, 20H2 - is available. It seems WUAPI doesn't return these updates, but I might be making a mistake.

I think it is possible to install these unattendedly by downloading the Windows 10 Update Assistant and calling it with some poorly documented flags, or by unpacking an .iso and calling setup.exe. But what I'd really like to have is the interface that the Windows settings app uses. I'd like to basically click on "Search for Updates" programmatically, see if a feature update is offered, and possibly install that.

It is not an solution to just unconditionally run setup.exe (I already know how to do that). Neither is "switching to WSUS", because the computer in question may or may not be managed by WSUS. I'd like to show the update if and when it is offered, no matter wheter it comes from Microsoft's servers or WSUS. Is there any way to do that (short up screen-scraping the settings app? :-D).

1

There are 1 answers

1
MartinC On

Have you seen Boxstarter.org ?

Automation of windows installs. But there is also an Install-WindowsUpdate function. Finds, downloads and installs all Windows Updates. By default, only critical updates will be searched. However the command takes a -Criteria argument allowing one to pass a custom Windows Update query.

Help Install-WindowsUpdate -Full

See https://boxstarter.org/WinConfig

This should give you any hidden updates:

Install-WindowsUpdate -criteria "IsHidden=1 and IsInstalled=0 and Type='Software' and BrowseOnly=1"

output:

++ Boxstarter starting Checking for updates...
Restarting windows update service
++ Boxstarter finished Checking for updates... 00:00:29.5201057
There is no update applicable to this machine