How do I remove unwanted updates from WSUS?

Depending on the products and classifications you have subscribed to, WSUS can become a storage hog. Manually declining updates to free up space is too time-consuming, and the Server Cleanup Wizard is ineffective. Luckily, a script from the TechNet Gallery can thoroughly erase unneeded updates.

  • Author
  • Recent Posts

How do I remove unwanted updates from WSUS?

Wolfgang Sommergut has over 20 years of experience in IT journalism. He has also worked as a system administrator and as a tech consultant. Today he runs the German publication WindowsPro.de.

How do I remove unwanted updates from WSUS?

Contents

  1. Emptying the content directory
  2. Declining and deleting updates using a script
  3. Adjusting criteria
  4. Starting the script

Even if you don't subscribe to many products and don't activate problematic classifications such as drivers or language packs, WSUS can quickly consume hundreds of GB of disk space. One trigger for this is automatic approvals, where activating the default rule is often enough to run out of disk space.

Emptying the content directory ^

Once the disk is full of updates, it seems like a good idea to delete them and then restart syncing. However, you will be disappointed if you hope that older or already superseded updates will not be downloaded again. All updates that have been previously approved will end up back on the disk. If you have deactivated the option to download only approved updates, you will even get all updates.

How do I remove unwanted updates from WSUS?

By default, WSUS only downloads the files for approved updates

In this case, the Server Cleanup Wizard does not achieve much because it only deletes expired and replaced updates, the latter only after 30 days. As a solution, some instructions on the web recommend uninstalling WSUS, removing the SUSDB database and updates, and starting from scratch. Of course, in this case, all settings and historical data will be lost.

If you want to avoid this, then you have to decline all updates that are no longer needed before you empty the wsuscontent directory. The updates would then no longer be downloaded. With hundreds or even thousands of updates, rejecting them manually is too time-consuming.

Declining and deleting updates using a script ^

The solution offered by Microsoft employee Nick Eales, with his PowerShell Script, is way more elegant. It declines updates for old OS and IE versions, for Windows on Itanium or language files, and then deletes them from the disk.

The filter criteria can be found in a lengthy if statement and are documented by comments. You may not want to apply some conditions. for example, declining all x86 updates if you still have 32-bit versions of Windows installed. In this case, you can simply comment out the corresponding lines.

Conversely, you will usually not need the updates for ARM64, so you can include them in the conditions of the if statement. This also applies to all other updates that are not needed.

Adjusting criteria ^

In some areas, the script requires a few adjustments. For example, the above described decline of x86 updates does not work because the regular expression is case-sensitive, but the LegacyName on Windows 10 contains a capital 'X.' Here, you should replace the match operator with imatch.

How do I remove unwanted updates from WSUS?

It is recommended to check the conditions of the _if_ statement and to adapt them if necessary

A similar problem occurs with language packs where the search expression is no longer effective. If you want to decline them, but, for example, intend to keep German and English language packs, you should replace

$\_.Title -imatch "language\\s" -or

with

($\_.Title -imatch "language" -and $\_.Title -notmatch "(DEU|ENG)") -or

Starting the script ^

Basically, you can execute the PowerShell script remotely by specifying the name of the server and the port number using the parameters WSUSServer and WSUSPort. All too often, however, WSUS servers that contain many updates abort the connection on long-running actions.

Subscribe to 4sysops newsletter!

How do I remove unwanted updates from WSUS?

During longer running remote operations the WSUS server is likely to terminate the connection. Therefore you should execute the script locally.

Therefore, you have a better chance for successful execution if you start the script directly on the WSUS server. There, you can simply run it without parameters via the command:

.\\Decline-Updates.ps1

How do I remove unwanted updates from WSUS?
How do I remove unwanted updates from WSUS?

How do I clean my WSUS database?

Under “Options” in the WSUS admin tool, you can find the cleanup wizard. This does not necessarily remove disk files you would expect and can need some encouragement by manually “unapproving” updates under “All Updates”. Follow the steps here to deselect updates you don't ever want and remove all updates from disk.

Can I delete WSUS content files?

It is not recommended to delete the files in the WSUSContent folder. But you can. After deleting you can run wsusutil.exe /reset [ENTER]. WSUS Content.

How do I clean up the WSUS content folder?

1 Answer.
Reduce the size of the WSUSContent folder by decreasing superseded updates..
It will clear all sync logs accumulated over time (configurable, with default keeping the last 14 days of logs)..
Remove all drivers from the WSUS database..
Remove declined updates from the WSUS database..
Run the server cleanup wizard..

How do I free up space on WSUS?

How to Clear Space on WSUS Server.
Shrinking your WSUS Content folder and declining superseded updates..
Cleaning out the synchronization logs..
Removing drivers from the WSUS database..
Removing declined updates..
Running the server cleanup wizard..
Running the recommended maintenance script on the SQL database..