我有一個我爲報告製作的powershell腳本。我在顯示安裝/不適用百分比更新時遇到問題。使用Powershell獲取已安裝/不適用的WSUS百分比
所以這裏是我創建的腳本的開始。
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration");
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer("WSUSSRV",$False);
##Get updates summary per computer##
$computerscope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope;
$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope;
$wsus.GetSummariesPerComputerTarget($updatescope,$computerscope) |
Format-Table @{L='ComputerTarget';E={($wsus.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName}},
@{L='NeededCount';E={($_.DownloadedCount + $_.NotInstalledCount)}},DownloadedCount,NotInstalledCount,InstalledCount,FailedCount,InstalledOrNotApplicablePercentage;
我遇到麻煩的部分是在最後的聲明。
Format-Table @{L='ComputerTarget';E={($wsus.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName}},
@{L='NeededCount';E={($_.DownloadedCount + $_.NotInstalledCount)}},DownloadedCount,NotInstalledCount,InstalledCount,FailedCount,InstalledOrNotApplicablePercentage;
正如您所看到的,這部分將顯示報表的表格。最後一個是InstalledOrNotAppableablePercentage。這是我有麻煩顯示的部分。我不知道這是否是正確的變量名稱,或者我錯過了什麼?
運行'$ wsus.GetSummariesPerComputerTarget($ updatescope,$ computerscope)| Get-Member -Force'可以查看輸出對象的所有成員(屬性和方法)。 – mklement0