Skip to content

Instantly share code, notes, and snippets.

@r-plus
Created April 11, 2014 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-plus/10445287 to your computer and use it in GitHub Desktop.
Save r-plus/10445287 to your computer and use it in GitHub Desktop.
# Get local wsus object.
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
$WsusServerAdminProxy = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
# Decline itanium updates.
$ItaniumUpdates = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match "IA64|Itanium" -and $_.Title -notmatch "x86|x64"}
If ($ItaniumUpdates) {
$ItaniumUpdates | %{$_.Decline()}
}
# Clean up.
$CleanupScope = new-object Microsoft.UpdateServices.Administration.CleanupScope;
$CleanupScope.CleanupObsoleteComputers = $false
$CleanupScope.CleanupObsoleteUpdates = $true
$CleanupScope.CompressUpdates = $true
$CleanupScope.CleanupUnneededContentFiles = $true
$CleanupScope.DeclineSupersededUpdates = $true
$CleanupScope.DeclineExpiredUpdates = $true
$CleanupManager = $WsusServerAdminProxy.GetCleanupManager();
$CleanupManager.PerformCleanup($CleanupScope) > C:\WsusCleanUp.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment