WSUS Console Freezes when the Server Cleanup Wizard

A common administration task of maintaining a WSUS server is cleaning up old legacy updates no longer required running the Server Cleanup Wizard.


If you have a large amount of updates which need cleaning, the Server Cleanup Wizard often freezes making it impossible to clean old updates from the WSUS Database.

If this happens, install SQL Management Studio onto the server an connect to the Windows Internal Database used by WSUS.

Run the following query to clean up old updates (this can take hours to run):


execspGetObsoleteUpdatesToCleanup

DECLARE@var1 INT
DECLARE @msg nvarchar(100)

CREATE TABLE#results (Col1 INT)
INSERT INTO#results(Col1) EXEC spGetObsoleteUpdatesToCleanup

DECLARE WC Cursor
FOR
SELECT Col1 FROM #results

OPEN WC
FETCH NEXT FROM WC
INTO@var1
WHILE (@@FETCH_STATUS > -1)
BEGIN SET @msg = 'Deleting ' + CONVERT(varchar(10), @var1)
RAISERROR(@msg,0,1) WITH NOWAIT EXECspDeleteUpdate @localUpdateID=@var1
FETCH NEXT FROM WC INTO@var1 END
CLOSE WC
DEALLOCATE WC
DROP TABLE#results


After a few hours the query should finish.  Once finished, you will need to run a "wsusutil reset" from an elevated command prompt.

"wsusutil reset" will also take a few hours to complete as it needs to scan every update on disk against the database and delete any that no longer exist in the database.

Hope this post has been helpful.
Previous
Next Post »