WSUS Clean - Powershell script

This little script will perform a clean up of declined and superceded updates in the WSUS database.  It uses the .Net class "Microsoft.UpdateServices.Administration" assembly, which should be loaded on your WSUS server. 

WSUS_Clean.ps1
 
 
 
 
 
4.5 Star
(12)
20,438 times
Add to favorites
Windows Update
7/3/2012
E-mail Twitter del.icio.us Digg Facebook
  • Decline superseded updates
    1 Posts | Last post October 07, 2019
    • Hi,
      
      I've checked your script and I can see that all superseded updates are not declined.
      Is there a specific condition, setting needed to be able doing that?
      
      Thannks in advance,
      Augustin
  • Decline superseded updates
    1 Posts | Last post October 07, 2019
    • Hi,
      
      I've checked your script and I can see that all superseded updates are not declined.
      Is there a specific condition, setting needed to be able doing that?
      
      Thannks in advance,
      Augustin
  • WSUS Invalid Server Exception calling GetUpdateServer()
    3 Posts | Last post February 15, 2014
    • As of Subject, I get such an exception executing WSUS_Clean.ps1 with PS 2.0 on my Win 2008 R2 x64 machine.
      As of http://msdn.microsoft.com/en-us/library/windows/desktop/ms745830%28v=vs.85%29.aspx, it could mean server can't be contacted, but it seems strange to me, since WSUS 3.0 SP2 with KB2734608 and KB 2720211 is up and running.
      Installed with all defaults (e.g. local IIS on port 80), except I use a remote SQL Server 2005 database for SUSDB.
      Script is esecuted on the same machine where WSUS 3.0 SP2 is executed.
      Full exception trace available on request.
    • It seems that ran into same issue.
    • works for me. I had to establish connection to the server first.
      
      $w  = [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
      $ww = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(“localhost”,$false,8530)
  • How do you get this script to run
    1 Posts | Last post May 19, 2013
    • Hi,
      I have downloaded script, set policy to unsigned all that is fine
      start powershell from Administrator
      run script 
      only the first line comes up and then it stops there ?
      any suggestions
      thanks