Skip to content

Instantly share code, notes, and snippets.

@rdark
Created September 2, 2014 14:57
Show Gist options
  • Save rdark/41d73f3e5dacaca7f18d to your computer and use it in GitHub Desktop.
Save rdark/41d73f3e5dacaca7f18d to your computer and use it in GitHub Desktop.
automate clean up of WSUS
# Script to clean up WSUS database
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
$cleanupScope = new-object Microsoft.UpdateServices.Administration.CleanupScope;
$cleanupScope.DeclineSupersededUpdates = $true
$cleanupScope.DeclineExpiredUpdates = $true
$cleanupScope.CleanupObsoleteUpdates = $true
$cleanupScope.CompressUpdates = $true
$cleanupScope.CleanupObsoleteComputers = $true
$cleanupScope.CleanupUnneededContentFiles = $true
$cleanupManager = $wsus.GetCleanupManager();
$cleanupManager.PerformCleanup($cleanupScope);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment