Forum Discussion
Calculate Percent on Compliance SCCM Powershell by Device collection
Hi,
I had a small question just to confirm that I understand your question, so what you need is to get the result for all the deployment packages which listed in the following line
$DeploymentID = Get-CMSoftwareUpdateDeployment | select AssignmentID, AssignmentName | Out-GridView -OutputMode Single -Title "Select a Deployment and Click OK" | Select -ExpandProperty AssignmentID
and get the percentage of how many deployment was success, failure ...etc
so the output will look like
Success: 40%
Error: 2%
Unknown: 50%
and so on, Yes?!
- NAN2019Oct 22, 2020Copper Contributor
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.
- farismalaebOct 24, 2020Iron Contributor
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.
- NAN2019Oct 25, 2020Copper Contributor
Tried it again and Thanks Faris. This works.
How can I limit this to only a specific Deployment ID?
How could I run this against my list of Device Collection Names perhaps from a txt file?