Thoroughly cleaning up a WSUS server

, , ,

I was recently tasked with performing a clean-up of some of our servers, removing old files/software installations as well as a clean-up of our WSUS server.  After a quick look I could see that our previous administrator had set it to download Driver updates as well, which was taking up quite a large amount of space and something that we wern’t really looking at using (no driver updates were approved).

So I ran the WSUS clean-up wizard, which removed some old computers, but the driver updates remained. I wanted them gone.  So I quickly made sure that driver updates category wasn’t selected and ran the following PowerShell script on the WSUS machine.

[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
$cleanupScope = new-object Microsoft.UpdateServices.Administration.CleanupScope;
$cleanupScope.DeclineSupersededUpdates = $true
$cleanupScope.DeclineExpiredUpdates         = $true
$cleanupScope.CleanupObsoleteUpdates     = $true
$cleanupScope.CompressUpdates                  = $true
#$cleanupScope.CleanupObsoleteComputers = $true
$cleanupScope.CleanupUnneededContentFiles = $true
$cleanupManager = $wsus.GetCleanupManager();
$cleanupManager.PerformCleanup($cleanupScope);

This script took about an hour to run but worked like a charm. It basically cleaned up the whole WSUS database, removing old computers, obsolete and unneeded updates (including the drivers I no longer wanted) as well as removing the associated update files which cleaned up a lot of space. The script above is modified so as not to remove computers from the database but that can be simply uncommented and included in the script.

Let me know in the comments if you found this useful.


3 responses to “Thoroughly cleaning up a WSUS server”

  1. Joel Avatar
    Joel

    Do you just copy and paste into a powershell window or do I need to save as a file and run?

    Thanks!

    1. John Avatar
      John

      Joel, better off having this as a file and then running it. But you can run it direct from the command line.

  2. Sine Avatar
    Sine

    Thank You John , This worked for me

Leave a Reply

More Posts

How to convert Hex Colour Codes into RGB Colour Codes using PHP

I was recently working on a web based piece of software that had some colour settings stored in a database table which were stored as hexadecimal colour code values. I needed a quick way to convert them into RGB (Red, Green, Blue) values so that I could use them in creating an image using PHPs […]

Backing up your EVA SAN (4400 or P63x0) Configuration with HP StorageWorks Storage System Scripting Utility (SSSU)

Just a short one today.  I was assisting in the change from a stand-alone Hyper-V environment to a clustered environment, the customer had an HP EVA P6300 SAN which was going to be used for the Clustered Shared Volumes.  As a precaution before beginning work on the EVA, I loaded up SSSU which was installed on […]

Getting a list of users in Active Directory as well as their Logon Script using dsquery and dsget

So I’m preparing on doing a clean-up of our NETLOGON/SYSVOL folder containing about 50 or so different logon scripts (plenty of which I know are no longer used).  I wanted to create a list of all of our active directory users along with what logon script they were assigned (I could then feed this list […]