How to identify core servers in SCCM

By | June 26, 2024

There is no easy way to detect core servers in SCCM by using the default inventory information. Here’s how to extend it to distinguish core and GUI servers.

Microsoft recommendation to check remotely if a server is running the core setup is to use the ServerLevels registry hive in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Server [1].

On a GUI server, we find these entries:

On a core server, you should find only ServerCore and perhaps ServerCoreExtended.

We’ll collect the 4 values with the hardware inventory and use Server-Gui-Shell for the detection.

Step 1: Use a mof file to extend the inventory:

Put the code below in a text file called ServerLevels.mof.

#pragma namespace (“\\\\.\\root\\cimv2”)
#pragma deleteclass(“ServerLevels_64”, NOFAIL)

[DYNPROPS]

Class ServerLevels_64
{
[key] string KeyName;
Uint32 Server_Gui_Mgmt;
Uint32 Server_Gui_Shell;
Uint32 ServerCore;
Uint32 ServerCoreExtended;
};

[DYNPROPS]

Instance of ServerLevels_64
{
KeyName=”ServerLevels_64″;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Server\\ServerLevels|Server-Gui-Mgmt”),Dynamic,Provider(“RegPropProv”)] Server_Gui_Mgmt;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Server\\ServerLevels|Server-Gui-Shell”),Dynamic,Provider(“RegPropProv”)] Server_Gui_Shell;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Server\\ServerLevels|ServerCore”),Dynamic,Provider(“RegPropProv”)] ServerCore;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Server\\ServerLevels|ServerCoreExtended”),Dynamic,Provider(“RegPropProv”)] ServerCoreExtended;
};

Save the file on any machine in your environment. For simplicity I use the primary site server.

Next, open a command prompt as admin and run the command:
mofcomp ServerLevels.mof


The output should look like this:


Next, select Client Settings from Administration, mark the Default Client Settings and go to Set Classes

Click Add and connect to the server that you compiled the ServerLevels.mof on.

Search the ServerLevels class and select it.

Close the dialogs with OK. In background, a table and view will be created in the database.

Next, open the configuration.mof from the installation directory of your Primary, the path should look similar to

E:\Program Files\Microsoft Configuration Manager\inboxes\clifiles.src\hinv

Make a backup of the existing mof and open the original file.

Scroll to the end and add the content of the ServerLevels.mof between Added extensions start and Added extensions end.

To see the result, create a collection.

Add a dynamic query either by selecting the class or by using the code below.

select *  from  SMS_R_System 
inner join SMS_G_System_SERVERLEVELS_64 on SMS_G_System_SERVERLEVELS_64.ResourceId = SMS_R_System.ResourceId
where SMS_G_System_SERVERLEVELS_64.Server_Gui_Mgmt is null

Click OK to close the query dialog.

Set an update interval and complete the Collection wizard.

Wait until the inventory fills the collection.

To check the status from the SQL Server Management Studio, run

select Name0, * from v_GS_SERVERLEVELS_64 sl
left join v_R_System sys on sys.ResourceID = sl.ResourceID



Links:

[1] Determining Whether Server Core Is Running
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/hh846315(v=vs.85)

 

Leave a Reply

Your email address will not be published. Required fields are marked *