$Searchstring="Preview of Monthly" [void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer(); $updateScope = New-Object Microsoft.UpdateServices.Administration.UpdateScope # Retrieve only updates that have not yet been approved $updateScope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::NotApproved # Retrieve only updates that are installable $updateScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::All $totalUpdateCount = $wsus.GetUpdateCount($updateScope) $qualityUpdates = $wsus.GetUpdates($updateScope) | Where-Object {$_.Title -like '*$Searchstring*'} $qualityUpdateCount = $qualityUpdates.Length if ($qualityUpdateCount -gt 0) { $wsus.GetUpdates($updateScope) | Where-Object {$_.Title -like '*$Searchstring*'} | ForEach { $_.Decline() } }