Here is a very short PowerShell one-liner that checks for missing Windows updates on the local computer:
(New-Object -ComObject Microsoft.Update.Session).CreateupdateSearcher().Search(“IsHidden=0 and IsInstalled=0”).Updates | Select-Object Title
An alternative way to do this is to use the Get-WindowsUpdate cmdlet to retrieve a list of available updates. To check for updates that have not yet been installed, you can use the -IsInstalled parameter and set it to $false:
Get–WindowsUpdate –IsInstalled $false
Both methods should return the same result – retrieve a list of updates that are available to be installed, but have not yet been installed on the system.
Here is another cool PowerShell one-liner script that installs all missing updates:
Get–WindowsUpdate –IsInstalled $false | Install–WindowsUpdate
This script will install all of the missing updates that were returned by the Get-WindowsUpdate cmdlet. You can also use the -MicrosoftUpdate parameter to specify that you want to install updates from Microsoft Update, rather than just Windows Update.
P.S. Checking for missing Windows updates via scripts is a very common troubleshooting technique utilized by users of commodity RMMs not specifically designed for patch management. Give Action1 a shot to see why it’s the best purpose-built patch management system. It’s free for your first 100 endpoints.