SQL: All Collections for a Specific Device or User

Photo of author
By Jeff LeBlanc

As an SCCM Admin, other than my daily dashboard, I honestly hardly ever run Reports for myself and instead I usually go straight to the source, the SQL DB! I find it faster and more flexible if I need to pull in additional data.

Here is a simple query to return all Collections a specific computer is in.

/* All Collections for a specific Device Name */
SELECT fcm.CollectionID, coll.Name, fcm.Name
FROM v_FullCollectionMembership AS fcm LEFT OUTER JOIN
v_Collection AS coll ON fcm.CollectionID = coll.CollectionID
WHERE fcm.Name = 'W11-XXXXXXX'
ORDER BY coll.Name

Alternatively you can return all User Collections based on User ID.

/* All Collections for a specific User Name */
SELECT fcm.CollectionID, coll.Name, fcm.Name
FROM v_FullCollectionMembership AS fcm LEFT OUTER JOIN
v_Collection AS coll ON fcm.CollectionID = coll.CollectionID
WHERE fcm.Name LIKE 'DOMAIN\USERID%'
ORDER BY coll.Name

Leave a Comment