1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| # auto-decline.ps1
# Updates auto-declining script : refusing 64 bits, wmp except v11, ie except ie7, some drivers
# Tested with WSUS 3.0 SP1
# 22 dec 08
[System.Reflection.Assembly]::LoadWithPartialName('microsoft.updateservices.administration') | out-null
$wsusrv=[Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer()
$unneededUpdates = 0
$wsusrv.GetUpdates() |
where { ($_.Isdeclined -eq $False) -and ( `
($_.Title.ToLower() -match 'ia64') `
-or ($_.Title.ToLower() -match 'itanium') `
-or ($_.Title.ToLower() -match 'x64') `
-or ($_.Title.ToLower() -match 'internet explorer 6') `
-or ($_.Title.ToLower() -match 'internet explorer 8') `
-or ($_.Title.ToLower() -match 'visio') `
-or ($_.Title.ToLower() -match 'onenote') `
-or ($_.Title.ToLower() -match 'infopath') `
-or ($_.Title.ToLower() -match 'project 2003') `
-or ($_.Title.ToLower() -match 'publisher 2003') `
-or ($_.Title.ToLower() -match 'nvidia') `
-or ($_.Title.ToLower() -match 'ati') `
-or ($_.Title.ToLower() -match 'windows media player 6.4') `
-or ($_.Title.ToLower() -match 'windows media player 8') `
-or ($_.Title.ToLower() -match 'windows media player 9') `
-or ($_.Title.ToLower() -match 'windows media player 10') `
-or ($_.IsSuperseded -eq "true") `
)} |
% {
$_ | ft -prop Title,ArrivalDate; $_.Decline() ; $unneededUpdates += 1
}
if ($unneededUpdates -gt 0)
{
"{0:N0} Unneeded Updates declined." -f $unneededUpdates
} else
{
Write-warning 'No update to decline'
} |