List the members of a collection
SQL query for the Configuration Manager database that lists every member of a collection you name, with domain, site code and client state.
LanguageSQL
What it does to the systemReads only. It changes nothing.
Sometimes you need the member list of a collection outside the console. For example, to compare two collections or to send a list to another team.
The result shows the collection, each member name, the domain, the site code and if the member has a client.
SQL
-- Type the exact name of the collection.
DECLARE @CollectionName NVARCHAR(255) = 'All Workstations';
SELECT
c.CollectionID AS CollectionID,
c.Name AS CollectionName,
fcm.Name AS MemberName,
fcm.Domain AS Domain,
fcm.SiteCode AS SiteCode,
fcm.IsClient AS HasClient
FROM v_Collection c
JOIN v_FullCollectionMembership fcm
ON fcm.CollectionID = c.CollectionID
WHERE c.Name = @CollectionName
ORDER BY fcm.Name;
How to use it
- Open SQL Server Management Studio and connect to the site database.
- Paste the query into a new query window.
- Change
@CollectionNameto the exact name of your collection. - Run the query.
- To use a collection ID, change the WHERE line to
c.CollectionID = 'ABC00012'.
Good to know
- The query works for device collections and user collections.
- The list is as fresh as the last membership evaluation of the collection.
collection
collection members
v_FullCollectionMembership
v_Collection
More SCCM SQL queries
List all collections a computer belongs to
Check BitLocker protection status for each computer
Check distribution point content status for a package
Check software update compliance for one update
Count computers by manufacturer and model
Count Configuration Manager client versions in your environment