There is a lot of resources available on Internet to create System Center Configuration Manager device collection based on the operating system but none are helpful to create a device collection to identify all Windows Core servers, especially Windows Server 2016 Core as there is no more switching between Core and UI.
So after digging around I found this MSDN resource which explains how to identify a core server (https://msdn.microsoft.com/en-us/library/hh846315(v=vs.85).aspx).
The following registry key identifies if the server is running with the UI, Core or Nano
NOTE the following will not apply to Windows 2008 or Windows 2008 R2 as the referenced key does not exist
Next you have to update SCCM to query the referenced key; to do so you need to update the configuration.mof and create a custom MOF file.
To generate all the appropriate code, you can use the RegKeyToMOF tool provided by MVP Mark Cochrane.(https://gallery.technet.microsoft.com/RegKeyToMof-28e84c28) to avoid error.
You have to run the tool from a server where the key exist (you can not remotely connect).
Then update the SCCM configuration by doing the following:
- Copy the existing configuration.mof file located in C:\Program Files\Microsoft Configuration Manager\inboxes\clifiles.src\hinv as configuration.mof.backup just in case
- Edit with notepad the configuration.mof file and reach the end of the file to locate the section
// Added extensions start
// Added extensions end
- Paste between the start and end the code generated in the configuration.mof tab in the RegKeyToMof tool and save the update configuration.mof file
- Next copy the code generated in the to import in Admin/AgentSettings/HardwareInventory/SetClasses/Import tab to a new text file you will save as .mof; save it to an accessible location to import it using the SCCM console
- Using SCCM console import your custom MOF file to the Hardware Inventory agent
- Wait for the SCCM client to get the updated configuration settings and you will be able to create a device collection identifying Windows Core server only or use the Client Notification to initiate the hardware inventory
- Finally you can create the device collection using the registry key; the query will be ServerLevels64 – Server_Gui_Mgmt is NULL
which is the following query
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_ServerLevels64 on SMS_G_System_ServerLevels64.ResourceID = SMS_R_System.ResourceId where SMS_G_System_ServerLevels64.Server_Gui_Mgmt is null