Created
April 11, 2014 06:57
-
-
Save r-plus/10445287 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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