Skip to content

Instantly share code, notes, and snippets.

@andreagx
Created January 23, 2014 15:17
Show Gist options
  • Select an option

  • Save andreagx/8580244 to your computer and use it in GitHub Desktop.

Select an option

Save andreagx/8580244 to your computer and use it in GitHub Desktop.
WSUS_Cleaner.ps1
[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