How to find ConfigMgr Collection membership of client via Powershell?

less than 1 minute read

During my session today at the ConfigMgr User Group in Zurich / CH I demoed a little Powershell function which will output all the Collection Names a device is a member of. Unfortunately, this cannot be done by default from the Admin Console.

I know there are Console extensions doing EXACTLY the same, but I know of people who don’t want to install any extensions not made available by the vendor. This is why I wrote this little snippet which in turn can easily be turned into a function.

$ResID = (Get-CMDevice -Name "CLTwin7").ResourceID
$Collections = (Get-WmiObject -Class sms_fullcollectionmembership -Namespace root\sms\site_HQ1 -Filter "ResourceID = '$($ResID)'").CollectionID
    foreach ($Collection in $Collections)
    {
      Get-CMDeviceCollection -CollectionId $Collection | select Name, CollectionID
    }

In line 1 just change the Name of the Client you want to check and in line 2 change the SiteCode (mine is HQ1). Because of lines 1 and 5 you need to import the ConfigMgr Powershell module first.

SCCM Collection Membership

Updated:

Leave a Comment