top of page
  • Writer's pictureshishir kushawaha

PowerShell to list device collections membership

Updated: Jan 29, 2023

The collections membership feature for a device is already available in the SCCM admin Console. However here's a handy piece of PowerShell that will quickly tell you what collections a device is a part of. The PowerShell script, on the other hand, can be used to alter the output or conduct other actions, such as sending a report to someone.


Below are the phases of the script.


1. It will connect to SCCM via MP server and sitecode at first.


2. After that, the user must specify the name of the device for which the collection membership is needed.


3. It then generates a report and saves it locally. This will come in handy later.


Sample Code


#Gathering ResourceID information of a device



$ResID = (Get-WmiObject -Namespace $Name_space -ComputerName $Server_name -Query "Select * from SMS_R_System where Name = '$($systemname)'").resourceid

#Gathering list of collections device is part of



$Collections = (Get-WmiObject -Class sms_fullcollectionmembership -Namespace $name_space -ComputerName $server_name -filter "resourceid = $resid").CollectionID

NOTE: Depending on the number of collection a device is part of, the script may take some time to complete.


You may find the source code at GitHub. Please leave any comment for the script or any suggestions. #MECM #SCCM #CollectionMembership

1,501 views0 comments

Recent Posts

See All
bottom of page