I have a powershell script I'm making for a report. I'm having trouble with displaying the Installed / Not Applicable Percentage for the updates.
So here's the beginning of the script I'm creating.
[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;
The part I'm having trouble with is in the last statement.
Format-Table @{L='ComputerTarget';E={($wsus.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName}},
@{L='NeededCount';E={($_.DownloadedCount + $_.NotInstalledCount)}},DownloadedCount,NotInstalledCount,InstalledCount,FailedCount,InstalledOrNotApplicablePercentage;
As you can see, this part will display the table for the report. The last one is InstalledOrNotApplicablePercentage. This is the part I am having trouble displaying. I do not know if this is the correct variable name for that or am I missing something?
There is no InstalledOrNotApplicablePercentage
property in the object but you can calculate that by adding a computed column which calculates it,like this :
Format-Table @{L='ComputerTarget';E={($wsus.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName}},
@{L='NeededCount';E={($_.DownloadedCount + $_.NotInstalledCount)}},DownloadedCount,NotInstalledCount,InstalledCount,FailedCount,@{L= "InstalledOrNotApplicablePercentage";e={(($_.NotApplicableCount + $_.InstalledCount) / ($_.NotApplicableCount + $_.InstalledCount + $_.NotInstalledCount+$_.FailedCount))*100}}