简体   繁体   中英

powershell windows missing updates

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.

There's a sample script from TechNet that does the core logic you're looking for:

Get-WindowsUpdates.ps1

There's also the older VBScript-based WUA_SearchDownloadInstall.vbs .

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...:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM