Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This will delete declined updates in a WSUS server.
- # It can be done in less lines, however there is a chance in poorly maintained WSUS servers of an SQL timeout.
- # Doing it in this way allows even partial runs to remove some data, so subsequent runs have more chance of succeeding.
- [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
- $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
- $ListOfUpdates=$wsus.getupdates() | where {$_.isdeclined -eq $TRUE}
- $listofupdates | measure | select count
- foreach ($UpdateToDelete in $ListOfUpdates) {
- $wsus.DeleteUpdate($UpdateToDelete.Id.UpdateId.ToString()); Write-Host $UpdateToDelete.Title removed }
- $ListOfUpdates=$wsus.getupdates() | where {$_.isdeclined -eq $TRUE}
- $listofupdates | measure | select count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement