These are all the words you think of in your head when you’re investigating what is happening with your WSUS server and realize that WSUS just ate all of your disk space and there is 0 bytes free. What do you do next?
If WSUS was downloading content at the time of the fill (which is the usual way things go), it has the downloads queued up and re-trying as space gets freed from the server. The first thing we want to do is cancel the downloads. Open a PowerShell window on the WSUS Server using ‘Run as administrator’ and run:
(Get-WsusServer).CancelAllDownloads()
Then we need to stop the WSUS Server service and the BITS services. Since we have PowerShell open already, let’s continue on there.
Stop-Service -Name WsusService,BITS -Force
Now that the services are stopped, try to delete Temporary files to free up some space.
Remove-Item -Path $env:LOCALAPPDATA\Temp\* -Recurse -ErrorAction SilentlyContinue Remove-Item -Path $env:SystemRoot\Temp\* -Recurse -ErrorAction SilentlyContinue
Now start the services again
Start-Service -Name WsusService,BITS
Launch the WSUS MMC Console, go into Options > Products and Classifications and review and uncheck any products that you don’t have in your network and/or any classifications that you don’t want to sync. Click OK and then perform a sync with Microsoft if you changed anything. This will expire any updates in those categories. Then try to run the Server Cleanup Wizard (SCW). If the SCW fails to run when all options are checked, try to run 1 at a time. Hopefully it will run through successfully and drop a few GB….. but you’re not done yet! What you’ve just done is an emergency recovery. The reason why you’ve had an issue is because you were NOT performing the proper routine maintenance that is needed on the WSUS System.
If the SCW does not finish running and you can’t recover some space (enough for you to continue on with doing the proper maintenance of WSUS), you may have to do a full WSUS_Content clear and reset.
Stop the WSUS Server service and the BITS services again.
Stop-Service -Name WsusService,BITS -Force
Now that the services are stopped, try to delete Temporary files to free up some space.
Remove-Item "$(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Update Services\Server\Setup' -Name 'ContentDir' | Select-Object -ExpandProperty 'ContentDir')\WsusContent\*" -Force
Now here’s the fun part. Go LOOK to see if you have any more space taken up by your WSUS Content folder where YOU think your content folder is. If you do, you have wasted space. This is a somewhat common occurrence when an IT Administrator decides to use the WSUSUtil.exe MoveContent and doesn’t delete the old location.
The registry has the CORRECT location to the WSUS Content folder.
"$(Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Update Services\Server\Setup' -Name 'ContentDir' | Select-Object -ExpandProperty 'ContentDir')\WsusContent\"
If you are not looking there you have duplicate files (like C:\WSUS\WsusContent\WsusContent is what the registry shows and you have files taking up space on C:\WSUS\WsusContent\, then you effectively have a NESTED WsusContent folder where you can remove all files and folders within C:\WSUS\WsusContent\* EXCEPT for the nested WsusContent folder within it.)
Now that we’ve cleaned the WsusContent folder, we need to start the services again.
Start-Service -Name WsusService,BITS
Now we need to run a WSUSUtil.exe Reset from within that PowerShell prompt.
& "$env:ProgramFiles\Update Services\Tools\WsusUtil.exe" Reset
Leave your WSUS Server alone for a full 24 hours. There are no notifications of when this process is running or finished. The reset will verify that every update metadata row in the WSUS database corresponds to update files stored in the local update file storage location on your WSUS server. If update files are missing or have been corrupted, WSUS downloads the update files again. Because we just wiped out the entire content folder, it will re-download every update file again so this process will take time and bandwidth. It will also leave you with a WORKING WSUS Server. There’s only 1 more step for you to do:
WAM Your Server™ so that this doesn’t happen again.