Create Query-Based SCCM Device Collections
In this article, I’ll walk you through step-by-step creation of query-based device collections, along with ready-to-use queries for:
- Windows Server 2016 / 2019 / 2022 / 2025
- All Servers
- Windows 11 (latest builds)
- Windows 10 versions
Step-by-Step: Create Query-Based Device Collection
Follow these steps in Microsoft Endpoint Configuration Manager console:
1. Open SCCM Console
- Go to Assets and Compliance
- Click on Device Collections
2. Create New Collection
- Right-click Device Collections
- Select Create Device Collection
3. General Settings
- Name: Enter collection name (e.g., Windows Server 2025)
- Limiting Collection: use All Systems
4. Add Membership Rule
- Click Add Rule → Query Rule
-
Provide:
- Name: e.g., Server 2025 Query
- Click Edit Query Statement
5. Add Query
- Go to Show Query Language
- Paste your query (from below sections)
6. Complete Wizard
- Click OK → Next → Close
7. Update Collection
- Right-click collection → Update Membership
🖥️ Windows Server 2025 Collection
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,
SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,
SMS_R_SYSTEM.Client
from SMS_R_System
inner join SMS_G_System_OPERATING_SYSTEM
on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId
where SMS_G_System_OPERATING_SYSTEM.BuildNumber = "26100"
AND SMS_G_System_OPERATING_SYSTEM.Caption LIKE '%Windows Server%'
🖥️ Windows Server 2019 Collection
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,
SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,
SMS_R_SYSTEM.Client
from SMS_R_System
INNER JOIN SMS_G_System_OPERATING_SYSTEM
ON SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceID
WHERE SMS_G_System_OPERATING_SYSTEM.Version = '10.0.17763'
AND SMS_G_System_OPERATING_SYSTEM.Caption LIKE '%Windows Server 2019%'
🖥️ Windows Server 2022 Collection
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,
SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,
SMS_R_SYSTEM.Client
from SMS_R_System
inner join SMS_G_System_OPERATING_SYSTEM
on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId
where SMS_G_System_OPERATING_SYSTEM.Version = "10.0.20348"
🖥️ Windows Server 2016 Collection
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,
SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,
SMS_R_SYSTEM.Client
from SMS_R_System
inner join SMS_G_System_OPERATING_SYSTEM
on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId
where SMS_G_System_OPERATING_SYSTEM.Version = "10.0.14393"
AND SMS_G_System_OPERATING_SYSTEM.Caption LIKE '%Windows Server 2016%'
🖥️ All Servers Collection
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,
SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,
SMS_R_SYSTEM.Client
from SMS_R_System
where SMS_R_System.OperatingSystemNameandVersion like "%Server 10.0%"Or You can use >Add Rule > Include collections, and select windows server versions separately
💻 Windows 11 (25H2)
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_OPERATING_SYSTEM.Version like "10.0.26200%" and SMS_G_System_OPERATING_SYSTEM.Caption not like "%Server%"