SHARE
TWEET

Delete declined updates in WSUS

anonit Oct 14th, 2018 (edited) 567 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # This will delete declined updates in a WSUS server.
  2.  
  3. # It can be done in less lines, however there is a chance in poorly maintained WSUS servers of an SQL timeout.
  4. # Doing it in this way allows even partial runs to remove some data, so subsequent runs have more chance of succeeding.
  5.  
  6. [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
  7. $wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
  8. $ListOfUpdates=$wsus.getupdates() | where {$_.isdeclined -eq $TRUE}
  9. $listofupdates | measure | select count
  10. foreach ($UpdateToDelete in $ListOfUpdates) {
  11.     $wsus.DeleteUpdate($UpdateToDelete.Id.UpdateId.ToString()); Write-Host $UpdateToDelete.Title removed }
  12. $ListOfUpdates=$wsus.getupdates() | where {$_.isdeclined -eq $TRUE}
  13. $listofupdates | measure | select count
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top