This tool can automate the cleanup process within WSUS.
The zip contains three files. The exe that performs the cleanup, an optional sql file that can be used to run the WSUS database maintenance script and a small help file. Just extract the files to a single directory and run the exe from a command line. The exe will then look for the sql file and if present run the SQL maintenance script.
Once the tool is complete it will create a log file within the same directory as the tool with the cleanup results but it will also log cleanup results to the application event log.
Create a scheduled task to run this tool monthly.
CL.exe Server SSL Port Parameter List
server = WSUS server name.
SSL = 't' if using SSL otherwise 'f'.
Port = port number WSUS is listening on. Default is '80' otherwise '8530'.
superseded = cleanup all superseded updates that are no longer needed.
expired = cleanup all expired unapproved updates.
obsolete = cleanup all expired updates regardless of their approval.
compress = cleanup previous revision of updates that are no longer deployable.
computers = cleanup computers that have not contacted the server in over 30 days.
files = cleanup unneeded content files.
DB = runs the database maintenance script (make sure the DB_maint.sql file is present).
all = if all is used all cleanup options above will be run.
The above command will prompt you to input the server name, SSL configuration and port number WSUS is listening on. This can be run against a local or a remote server and runs ALL cleanup options.
CL.exe SomeServer t 8530 all
The above command will connect to SomeServer on port 8530, use SSL and cleanup with all options.
CL.exe SomeServer f 80 computers superseded
The above command will connect to SomeServer on port 80, it will not use SSL and cleanup will only run the computers and superseded options (no other cleanup options will run).
If you get a SQL timeout while running the tool I would recommend trying to run the cleanup initially from management studio or use sqlcmd as described here:
The timeout in studio manager or sqlcmd should allow for longer execution time. Once you run it initially and get the database cleaned up the subsequent runs with this tool should work.