Moin,
hab' ein paar Probleme mit einem Powershell Script für die WSUS Updates.
1. Ich möchte alle außer die englischen und deutschen Language Packs ablehnen per Code.
Wenn ich aber den folgenden Code anwende, dann werden mir beide trotzdem aufgelistet.
Wenn ich beispielsweise nur einen IF Block anwende, dann klappt es jeweils für Deutsch oder Englisch, aber nicht beide hintereinander, total seltsam?!
#Change server name and port number and $True if it is on SSL [String]$updateServer1 = "xxxx-WSUS01" [Boolean]$useSecureConnection = $False [Int32]$portNumber =8530 # Load .NET assembly [void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") $count = 0 # Connect to WSUS Server $updateServer = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer1,$useSecureConnection,$portNumber) write-host "<<<Connected sucessfully >>>" -foregroundcolor "yellow" $updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope $u=$updateServer.GetUpdates($updatescope ) $flag = "no" foreach ($u1 in $u ) { if(($u1.Title -ilike '*Lang*' -and $u1.Title -notlike '*en-*')){$flag = "yes"} if(($u1.Title -ilike '*Lang*' -and $u1.Title -notlike '*de-*')){$flag = "yes"} if($flag -eq "yes"){ write-host Decline Update : $u1.Title } $flag = "no" }
2. Wenn ich die superseeded Updates vorher manuell ablehne und lösche, werden mir trotzdem 1700 mit folgender Abfrage aufgelistet. In der letzten Zeile wird dann die Server Reinigung ausgeführt und es zeigt mir dann auch 0 an. Wieso?
#Source: https://docs.microsoft.com/de-de/archive/blogs/sudheesn/powershell-script-to-decline-all-superseded-updates-in-wsus #Declining superseeded Updates #Change server name and port number and $True if it is on SSL [String]$updateServer1 = "xxxx-WSUS01" [Boolean]$useSecureConnection = $False [Int32]$portNumber =8530 # Load .NET assembly [void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") $count = 0 # Connect to WSUS Server $updateServer = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($updateServer1,$useSecureConnection,$portNumber) write-host "<<<Connected sucessfully >>>" -foregroundcolor "yellow" $updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope $u=$updateServer.GetUpdates($updatescope ) foreach ($u1 in $u ) { if ($u1.IsSuperseded -eq 'True') { write-host Decline Update : $u1.Title $u1.Decline() $count=$count + 1 } } write-host Total Declined Updates: $count trap { write-host "Error Occurred" write-host "Exception Message: " write-host $_.Exception.Message write-host $_.Exception.StackTrace exit }
#Orginal: Get-WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteComputers -CleanupObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates -DeclineExpiredUpdates -DeclineSupersededUpdates -Confirm:$false | Add-Content $output
#Clean Server
Ge
VG