I normally set the below script on a weekly schedule. If you haven’t run this for a long period of time. It may crash out, but you’ll find that the cleanups are going through and eventually it will complete.
The stats write to a log file.

$DateFormat = Get-Date -format yyyymmdd
$Logfile = "C:\Source\wsuslogs\$Dateformat.log"

# WSUS Cleanup
Invoke-WsusServerCleanup -CleanupObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates -DeclineExpiredUpdates -DeclineSupersededUpdates | Out-File $Logfile

Leave a Reply

Your e-mail address will not be published. Required fields are marked *