Forum Discussion
Calculate Percent on Compliance SCCM Powershell by Device collection
1) Yes. I would like to show a clear percentage of each status (for example: Success 12% , 40% failed), for the Software update deployment.
2) The 2nd request was to take the specific software update deployment and run it against device collection names. Maybe the device collection could either be in a for-each statement or if its possible to take the device collection name itself and do it. So in a sense I would have:
Chicago - 75% success, 25% failed, 0% In progress, 0% failed
Cleveland - 25% success, 25% failed, 50% In progress, 0% failed
Houston - 75% success, 25% failed, 0% In progress, 0% failed
Miami - 0% success, 25% failed, 25% In progress, 50% failed
And I would like it to be in a csv as well as in the txt body of an email sent every morning.
I wrote a quick update for script, review the change and test it, I don't have a big SCCM env, but this seems to be as you want.
Function Get-AllPackages{
$AllPack = Get-CMSoftwareUpdateDeployment | select AssignmentID, AssignmentName
return $AllPack
}
$Packages= Get-AllPackages
foreach ($SinglePack in $Packages) {
Write-Host "--------------"
Write-Host $SinglePack.AssignmentName
$packinfo=Get-SCCMSoftwareUpdateStatus -DeploymentID $SinglePack.AssignmentID
$Status=$packinfo.status | Get-Unique
foreach ($sinlgestatus in $Status){
Write-Host "The Status of $($sinlgestatus) for $($SinglePack.AssignmentName)"
((($packinfo | where {$_.status -like $sinlgestatus})).status.count / ($packinfo.Count -4)).tostring("P")
}
}
There is no change on the main function, I added extra function and some foreach loop to get the status.
Hope it helps
---------------
If the above reply answers your question, please don't forget to click on Best Response.