Benutzer mit den meisten Antworten
Wsus Management mittels Powershell

Frage
-
Hallo zusammen
Ich stehe wieder einmal vor einem Problem.
Bin schon seit Stunden am herumprobieren und testen.
Ziel:
- Von jeder Wsus-Gruppe alle Clients auslesen und bei diesen, den Update-Stand "filtern"
- Es sollen pro Client nur Updates angezeigt werden, welche Approved sind, aber noch nicht installiert oder nur heruntergeladen + solche die Status Failed haben.Was ich bisher geschafft habe:
- Verbindung zum Wsus
- Herauslesen aller Clients, aber nicht pro Gruppe nur Global
- Herauslesen von verschiedenen Eigenschaften pro Client (Needed, Downloaded,NotApplicable,NotInstalled,Installed und Failed Updates)
- Bei Needed hätte es alle die gebraucht werden, jedoch auch welche die "not approved" sind.Ich hoffe ihr versteht was ich will und könntent mir ein bisschen auf die Sprünge helfen.
Meine genutzten Links:
http://blogs.technet.com/b/heyscriptingguy/archive/2012/01/21/introduction-to-poshwsus-a-free-powershell-module-to-manage-wsus.aspxAnhang Script:
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null $Global:WSUS = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(‘Wsus-Server’,$False) $computerscope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope $updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope $updatescope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::Any $updatescope.ExcludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Installed $Global:WsusListAny = New-Object system.Collections.ArrayList $Global:WSUS.GetSummariesPerComputerTarget($updatescope,$computerscope) | %{ $WsusObj = New-Object PsObject $WsusObj | Add-Member -MemberType NoteProperty "ComputerTarget" -Value ($Global:WSUS.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName $WsusObj | Add-Member -MemberType NoteProperty "NeededCount" -Value ($_.DownloadedCount + $_.NotInstalledCount) $WsusObj | Add-Member -MemberType NoteProperty "DownloadedCount" -Value $_.DownloadedCount $WsusObj | Add-Member -MemberType NoteProperty "NotApplicableCount" -Value $_.NotApplicableCount $WsusObj | Add-Member -MemberType NoteProperty "NotInstalledCount" -Value $_.NotInstalledCount $WsusObj | Add-Member -MemberType NoteProperty "InstalledCount" -Value $_.InstalledCount $WsusObj | Add-Member -MemberType NoteProperty "FailedCount" -Value $_.FailedCount $Global:WsusListAny.add($WsusObj)| out-null }
Grüsse Powerturtle
Antworten
-
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null $Global:WSUS = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(‘wsusserver,$False) $WsusClients = $Members | %{$Global:Wsus.GetComputerTargetByName($_)} #Updatescope definieren (Welche Updates geprüft werden sollen pro Client) $UpdateScope = New-Object Microsoft.UpdateServices.Administration.UpdateScope $UpdateScope.ExcludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Installed, [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::NotApplicable, [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Unknown $Global:WsusInformationArr = New-Object system.Collections.ArrayList #Für jeden Client soll es all diese Updates holen und auf die UpdateApprovalAction prüfen #Danach zusammezählen und ausgeben Foreach ($WsusClient in $WsusClients) { $WsusObj = New-Object PsObject $WsusObj | Add-Member -MemberType NoteProperty "ComputerTarget" -Value $WsusClient.FullDomainName $WsusObj | Add-Member -MemberType NoteProperty "Updates" -Value ($WsusClient.GetUpdateInstallationInfoPerUpdate($UpdateScope) | ? {$_.UpdateApprovalAction -ne "NotApproved"}).count If($WsusObj.Updates -eq $null){$WsusObj.Updates = "0"} $Global:WsusInformationArr.add($WsusObj) | out-null }
- Als Antwort markiert Powerturtle Montag, 13. August 2012 08:13
- Tag als Antwort aufgehoben Denniver ReiningMVP, Moderator Montag, 13. August 2012 08:45
- Als Antwort markiert Denniver ReiningMVP, Moderator Montag, 13. August 2012 08:45
Alle Antworten
-
Hi,
bietet denn das Modul PoshWSUS http://poshwsus.codeplex.com/ die Funktion, die Du suchst?
Ich würde ein fertiges Modul immer vorziehen...
-Raimund
-
Kleiner Nachtrag:
Mittels diesen Properties, filtert es nach dem richtigen
$computerscope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope $computerscope.NameIncludes = "server1.ad.test" $updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope $updatescope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::LatestRevisionApproved, [Microsoft.UpdateServices.Administration.ApprovedStates]::HasStaleUpdateApprovals $Global:WSUS.GetSummariesPerComputerTarget($updatescope,$computerscope)
Das Problem ist nur, dass sich die Approval Global auswirkt, dass heisst folgendes:
Wsus
-> Gruppe 1
-> Gruppe 2 (Standort server1.ad.test)Ist nun ein Update in Gruppe eins auf "Install" gestellt, wird es im Report auch als solche angezeigt, obwohl es bei Gruppe 2 auf "NotApproved" wäre und somit nicht gezählt werden müsste, da es logischerweise ja auch nie installiert wird, solange es auf *notApproved* ist.
- Bearbeitet Powerturtle Dienstag, 7. August 2012 05:55
-
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null $Global:WSUS = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(‘wsusserver,$False) $WsusClients = $Members | %{$Global:Wsus.GetComputerTargetByName($_)} #Updatescope definieren (Welche Updates geprüft werden sollen pro Client) $UpdateScope = New-Object Microsoft.UpdateServices.Administration.UpdateScope $UpdateScope.ExcludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Installed, [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::NotApplicable, [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Unknown $Global:WsusInformationArr = New-Object system.Collections.ArrayList #Für jeden Client soll es all diese Updates holen und auf die UpdateApprovalAction prüfen #Danach zusammezählen und ausgeben Foreach ($WsusClient in $WsusClients) { $WsusObj = New-Object PsObject $WsusObj | Add-Member -MemberType NoteProperty "ComputerTarget" -Value $WsusClient.FullDomainName $WsusObj | Add-Member -MemberType NoteProperty "Updates" -Value ($WsusClient.GetUpdateInstallationInfoPerUpdate($UpdateScope) | ? {$_.UpdateApprovalAction -ne "NotApproved"}).count If($WsusObj.Updates -eq $null){$WsusObj.Updates = "0"} $Global:WsusInformationArr.add($WsusObj) | out-null }
- Als Antwort markiert Powerturtle Montag, 13. August 2012 08:13
- Tag als Antwort aufgehoben Denniver ReiningMVP, Moderator Montag, 13. August 2012 08:45
- Als Antwort markiert Denniver ReiningMVP, Moderator Montag, 13. August 2012 08:45