In order to create a new device collection in SCCM, we first need the OS Version of the computers we want to be added automatically to this collection.

For Windows Server 2022 the OS version is 10.0.20348 and can be determined by running the systeminfo command as shown below.


OS versions
Windows Server 2012 –> 6.2.9200
Windows Server 2012 R2 –> 6.3.9600
Windows Server 2016 –> 10.0.14393
Windows Server 2019 –> 10.0.17763
Windows Server 2022 –> 10.0.20348


Btw. regarding OS version and naming for Windows Server 2022. When you want to use WSUS for Windows Server 2022 updates, you will find them in Products and Classifications as usual in the Windows section but with the names as of today Microsoft Server operating system-21H2 and Microsoft Server operating system-22H2.


Now we can start to create the new device collection in SCCM. Therefore go to SCCM –> Assets and Compliance –> Device Collection and click on Create Device Collection.

Enter a name for the collection and under limiting collection I will use All Systems.


Click on Add Rule and select Query Rule.


Click on Edit Query Statement


Click on Show Query Language


Insert the following Query for Windows Server 2022 and click on OK.

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" and SMS_G_System_OPERATING_SYSTEM.Caption = "Microsoft Windows Server 2022 Datacenter" OR SMS_G_System_OPERATING_SYSTEM.Caption = "Microsoft Windows Server 2022 Standard"


You can also use wildcards for the name and main version to query like the following for Windows Server 2012.

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 6.2%"



Click on Next


After closing the device collection will by default update the membership based on the query. You can also start the update manual by right clicking on it and select Update Membership.




Links

How to create collections in Configuration Manager
https://learn.microsoft.com/en-us/mem/configmgr/core/clients/manage/collections/create-collections

Introduction to collections in Configuration Manager
https://learn.microsoft.com/en-us/mem/configmgr/core/clients/manage/collections/introduction-to-collections

Best practices for collections in Configuration Manager
https://learn.microsoft.com/en-us/mem/configmgr/core/clients/manage/collections/best-practices-for-collections