How To Clean Up WSUS

I recently added Windows 10 to my WSUS Product and Classifications and got very surprised by the 100 GB of updates that was queued for download! Let’s learn how to clean up WSUS content folder.

Unfortunately, cancelling the download queued is not that straight forward, so I decided to use the opportunity to clean up my WSUS content folder and reclaim my VMFS datastore at the same time.

The reason why the updates where 100 GB was because I had all Classifications selected and an Automatic Approval Rule! After the changes below the updates where only 1 GB.

Lesson Learned, Be Careful with Automatic Approval Rules…

Clean Up WSUS

Clean Up WSUS 01

Before you start make sure to disable your Automatic Approval Rule(s). I have a very nice script below that saved me 300% of downloads.

Clean Up WSUS 02

It’s also a good time to verify that only the Products and Languages you actually need are selected.

From Update Files and Languages, make sure that you don’t have Express installation files selected.

Clean Up WSUS 03

Let’s clean up WSUS by running the following commands:

Take a look in Task Manager and you’ll see that the process “SQL Server Windows NT – 64 bit” is consuming all the CPU. This is because all database tables are being checked and any missing hotfixes are being marked for download.

This could take up to 30-60 minutes to complete, depending on the Products and Classifications you have. When the CPU drops you’re ready to proceed.

Let’s start Synchronization.

Clean Up WSUS 07

The thing with WSUS is that it’s going to download everything, even superseded updates. Now the purpose of this post is to also reclaim VMFS storage, so downloading all and then deleting them won’t help much. Luckily there’s a script for that.

Clean Up WSUS 09

WOW! Do you belive that? Out of 6467 updates, 4179 where declined.

Now run the Automatic Approval Rule to start the downloads.

Clean Up WSUS 10

Many people might argue that is unnecessary to run the wsusutil.exe reset command, simply because all updates will be re-downloaded.

Well, you could always search and decline all updates you don’t want and then run the Server Cleanup Wizard, but its PITA.

My WSUS folder went from 75 GB to 20 GB so I’m happy.

Reclaim VMFS Datastore

I’m not sure if you’re aware, but when you’re using Thin Provisioning it doesn’t matter if you delete unwanted files. When the space has been alllocated it will stay that way until you do the following steps below.

My WSUS folder was located on C: then moved to D: and finally E:

To reclaim the space after all unnecessary files has been deleted run sDelete on all volumes.

When finished shutdown the VM and connect to your ESXi host through Putty.

Navigate to your VMFS datastore folder for that VM.

Now run the following command for all disks:

Clean Up WSUS 04

Power up the VM and enjoy. I reclaimed 120 GB in 2 hours on just 1 VM!

Clean Up WSUS 05

Clean Up WSUS 06


19 Responses to How To Clean Up WSUS

  1. Hi
    thanks for the script however my server name has a hyphen “abc-def” and the script errors!

  2. Maybe this is obvious and I’m just being dense, but in the batch file what is the “echo Delete WSUS Folder Content” for? Am I supposed to manually delete this folder and then allow the batch file to continue?

  3. The script to decline the updates keeps failing. Getting this when trying to run it:

    Error Occurred
    Exception Message:
    The specified string is invalid.
    Parameter name: ServerName
    at Microsoft.UpdateServices.Administration.AdminProxy.CreateUpdateServer(Object[] args)
    at CallSite.Target(Closure , CallSite , RuntimeType , Object , Object , Object )

      • Still getting error

        Error Occurred
        Exception Message:
        The specified string is invalid.
        Parameter name: ServerName
        at Microsoft.UpdateServices.Administration.AdminProxy.CreateUpdateServer(Object[] args)
        at Microsoft.UpdateServices.Administration.AdminProxy.GetUpdateServer(String serverName, Boolean useSecureConnection, Int32 portNumber)
        at GetUpdateServer(Object , Object[] )
        at System.Management.Automation.MethodInformation.Invoke(Object target, Object[] arguments)
        at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)

  4. Great post used it on a new WSUS setup. Before doing your steps I was it over 300 GB of updates. Redid the sever now only downloading 62 GB. Total Declined Updates: 3690


  5. it should be: “.\WsusUtil.exe reset” otherwise you get an error that it cannot find the program (“mistyped”)

Leave a reply