I need to get all the users being part of a collecionID
on a SCCM server
Variables
$CollectionID = COLLID046
$SiteCode = XYZ
$SiteServer = SITEXYZ0
$Users = Get-WmiObject -Class SMS_FullCollectionMembership -Namespace root/SMS/site_$($SiteCode) -ComputerName $SiteServer | Where-Object -FilterScript {$_.CollectionId -eq $CollectionID} | Select-Object SMSID
This work fine and return all the users, but has the side effect that if you have a lot of collectionID
the where clause will circle all the collection before find the one you are looking and could take long time.
There is way to point directly to a specific collection?