List available Windows updates and filter out Security intelligence update from output list in PowerShell

Viewed 45

I have the following code, which can find the all available Windows updates:

$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateupdateSearcher()
$Updates = @($UpdateSearcher.Search("IsHidden=0 and IsInstalled=0 and AutoSelectOnWebSites = 1").Updates)
$Title = $Updates.Title
$Title

This produces the below output:

2022-08 Security Update for Windows Server 2016 for x64-based Systems (KB5012170)
Windows Malicious Software Removal Tool x64 - v5.105 (KB890830)
2022-09 Cumulative Update for Windows Server 2016 for x64-based Systems (KB5017305)
2022-09 Servicing Stack Update for Windows Server 2016 for x64-based Systems (KB5017396)
Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.375.750.0)

My question is how do I filter out an update which I don't want from the list?

E.g. Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.375.750.0)

1 Answers

For anyone who would need this in the future, this is what I did to omit the Security Intelligence Update from the list.

I Simply had to filter the objects using the Where-Object and -notlike operator. Also, since I only need the title of the update, used Select-Object for that.

$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateupdateSearcher()
$Updates = @($UpdateSearcher.Search("IsHidden=0 and IsInstalled=0 and AutoSelectOnWebSites = 1").Updates) `
| Where-Object {$_.Title -notlike "Security Intelligence Update for Microsoft Defender Antivirus*"} `
| Select-Object {$_.Title}

I use this script to automate the check for available monthly Windows updates and create a ticket for our engineers just in case patch management has failed to update any of our customers' servers. Security Intelligence is not considered critical and a new update is pretty made available a few times daily, so I don't want that to clog our ticketing system.

Related