Created
October 12, 2016 18:50
-
-
Save gen0cide/5bd7df12a73f50ba5a6965058ccca74f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Searcher = New-Object -ComObject Microsoft.Update.Searcher | |
$RemoveCollection = New-Object -ComObject Microsoft.Update.UpdateColl | |
$SearchResult = $Searcher.Search("IsInstalled=1") | |
$SearchResult.Updates | % { $RemoveCollection.Add($_) } | |
if ($RemoveCollection.Count -gt 0) { | |
$Installer = New-Object -ComObject Microsoft.Update.Installer | |
$Installer.Updates = $RemoveCollection | |
$Installer.Uninstall() | |
} else {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment