Reputation: 49
Trying to create powershell script to list missing or pending windows update. The purpose would be to run the script against a list of computers/servers to see if there are any missing updates or hot-fixes and generate a list of what servers you need to look at.
Does anyone have a solutions for this, have been looking around without any success finding scripts to do this.
Upvotes: 1
Views: 17515
Reputation: 256711
Powershell script to list missing updates
Script:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
#List all missing updates
Write-Output "Creating Microsoft.Update.Session COM object"
$session1 = New-Object -ComObject Microsoft.Update.Session -ErrorAction silentlycontinue
Write-Output "Creating Update searcher"
$searcher = $session1.CreateUpdateSearcher()
Write-Output "Searching for missing updates..."
$result = $searcher.Search("IsInstalled=0")
#Updates are waiting to be installed
$updates = $result.Updates;
Write-Output "Found $($updates.Count) updates!"
$updates | Format-Table Title, AutoSelectOnWebSites, IsDownloaded, IsHiden, IsInstalled, IsMandatory, IsPresent, AutoSelection, AutoDownload -AutoSize
pause
Sample output:
Creating Microsoft.Update.Session COM object
Creating Update searcher
Searching for missing updates...
Found 4 updates!
Title AutoSelectOnWebSites IsDownloaded IsHiden IsInstalled IsMandatory IsPrese
nt
----- -------------------- ------------ ------- ----------- ----------- -------
Intel - Other hardware - Intel(R) Xeon(R) E3 - 1200/1500 v5/6th Gen Intel(R) Core(TM) PCIe Controller (x16) - 1901 False False False False False
Intel - Other hardware - Intel(R) Xeon(R) E3 - 1200/1500 v5/6th Gen Intel(R) Core(TM) Gaussian Mixture Model - 1911 False False False False False
Microsoft Silverlight (KB4481252) False False False False False
SQL Server 2019 RTM Cumulative Update (CU) 4 KB4548597 False False False False False
Press Enter to continue...:
Upvotes: 3
Reputation: 32170
There's a sample script from TechNet that does the core logic you're looking for:
There's also the older VBScript-based WUA_SearchDownloadInstall.vbs.
Upvotes: 1