Forum Discussion
Calculate Percent on Compliance SCCM Powershell by Device collection
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?
For the first question you can add a parameter to your script SinlgeDeploymentID, and check if the value is present the parse this value, otherwise do it all 🙂
I did this
NOTE: I try to make the script as simple as possible to make it easier for others too.
Add this parameter on the top of your script
[CmdletBinding()]
param(
$GetonlyOne
)
in the script body add
if ($GetonlyOne -notlike $null){
Get-SCCMSoftwareUpdateStatus -DeploymentID $GetonlyOne
return
}
For the second one, its just like the first one but change the filter to match the collection Name you want
--------------------------------------
Thanks
If this answer fit your question, please mark this as Best Response and give Like 🙂
- NAN2019Oct 25, 2020Copper Contributor
farismalaeb
thanks.Where does my specific Assignment ID number go or how should it fit within your script above?
Can you please show me an example of one?Also how would my List of device collection Names fit into your script if they are being pulled from a text file?
- farismalaebOct 26, 2020Steel Contributor
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 16777338
and 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.
- NAN2019Oct 26, 2020Copper Contributor
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...