Forum Discussion
Calculate Percent on Compliance SCCM Powershell by Device collection
I did another small update to provide a better output for a single Assignment ID
if ($GetonlyOne -notlike $null){
Write-Host $SinglePack.AssignmentName
$packinfo=Get-SCCMSoftwareUpdateStatus -DeploymentID $GetonlyOne
$Status=$packinfo.status | Get-Unique
foreach ($sinlgestatus in $Status){
Write-Host "The Status of $($sinlgestatus) for $($GetonlyOne)"
((($packinfo | where {$_.status -like $sinlgestatus})).status.count / ($packinfo.Count -4)).tostring("P")
}
return
}
$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")
}
} The call should be like this
.\ScriptName -GetonlyOne 16777338and the output should be similar to this
WindowsServer 2016_2_2020-10-15 17:03:49
The Status of InProgress for 16777338
9.09 %
The Status of Success for 16777338
90.91 %
For the second one, I really did not understand how you want to fit the Collection Name here. can you explain a requirement to understand it.
Thanks Faris. For some reason your Original script is still pulling all deployments. Still not limiting it to one deployment. I Have the new code in another Powershell file. I run your above command with ID and it still pulls all assignments.
Any ideas?
For Device collection what I would like to do is pull the compliance status for one Assignment ID but for a list of device collections Inside a text file. So basically if I can take that Assignment ID and have it check all devices (Likely from SCCM’s database) and then show a percent. For example So again:
Chicago Devices.... Success 80% Error 20%
Los Angeles Devices ... Success 15% Error 85%
Denver Devices .... In Progress 50% Error 50%
Cleveland Devices And so on...
- farismalaebOct 27, 2020Iron Contributor
If you are calling the script without passing the
-GetonlyOneparameter with its value (which you can get from the following line)
Get-CMSoftwareUpdateDeployment | select AssignmentID, AssignmentName | Out-GridView -OutputMode Single -Title "Select a Deployment and Click OK" | Select -ExpandProperty AssignmentIDthen it will get all the software deployment package with their overall status, depend on what status is available in the Deploymentpackage state.
Can you please share the screenshot of the output you are getting