How to check if latest Windows Updates are installed via PowerShell?

Solution 1:

I suggest identifying exactly which updates are dependencies for Docker to work properly, and verifying those are installed specifically. It's surprisingly hard to emulate the "Check for Updates" button in PowerShell.

These are the built in commands, but they aren't documented and are just wrappers for WMI method calls.

Get-Command -Module WindowsUpdateProvider

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-WUAVersion                                     1.0.0.2    WindowsUpdateProvider
Function        Get-WUIsPendingReboot                              1.0.0.2    WindowsUpdateProvider
Function        Get-WULastInstallationDate                         1.0.0.2    WindowsUpdateProvider
Function        Get-WULastScanSuccessDate                          1.0.0.2    WindowsUpdateProvider
Function        Install-WUUpdates                                  1.0.0.2    WindowsUpdateProvider
Function        Start-WUScan                                       1.0.0.2    WindowsUpdateProvider

Documentation Team issue discussing lack of documentation https://github.com/MicrosoftDocs/windows-powershell-docs/issues/139

PowerShell Team issue discussing the broken functionality https://github.com/PowerShell/PowerShell/issues/5718

This person seems to have figured out how to use the commands. https://richardspowershellblog.wordpress.com/2017/11/17/windows-update-change-in-server-1709/

PS>  $au = Invoke-CimMethod -Namespace root/microsoft/windows/windowsupdate  -ClassName MSFT_WUOperations -MethodName  ScanForUpdates -Arguments @{SearchCriteria="IsInstalled=0"}

PS>  Invoke-CimMethod -Namespace root/microsoft/windows/windowsupdate  -ClassName MSFT_WUOperations -MethodName  InstallUpdates -Arguments @{Updates = $au.Updates}