Compartir a través de


How to Get the Unique Identifier Value for a Client

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

When you discover system resource data for a client, in Microsoft System Center Configuration Manager 2007, you must specify the client's unique identifier value in the data discovery record (DDR), such as:

DDRAddString("SMS Unique Identifier",
             "GUID:12345678-1234-1234-1234-123456789012", 64,
             ADDPROP_GUID | ADDPROP_KEY);

The client's unique identifier can be found in Windows Management Instrumentation (WMI) at:

root\ccm:CCM_Client=@:ClientId

Procedures

To identify the client's unique identifier in WMI

  1. Connect to the CCM namespace (root\ccm).

  2. Load the CCM_Client class.

  3. Enumerate through the objects in the CCM_Client class and display the unique identifier (ClientId).

Example

Description

The following example method shows how obtain the client's unique identifier from WMI by connecting to the CCM namespace, loading the CCM_Client class and getting the ClientId property.

Important

The following C# example requires the System.Management namespace.

For information about calling the sample code, see How to Call a Configuration Manager Object Class Method by Using WMI

Code

Sub GetClientUniqueID()

    ' Get a connection to the root\ccm namespace on the local system.
    Set objWMIService = GetObject("winmgmts:\\.\root\ccm")
    
    ' Get all objects in the CCM_Client class.
    set allCCMClientObjects = objWMIService.ExecQuery("Select * from CCM_Client")
    
    ' Loop through the available objects (only one) and display ClientId value.
    For Each eachCCMClientObject in allCCMClientObjects
       wscript.echo "ClientId (GUID): " & eachCCMClientObject.ClientId       
    Next 
   
End Sub
public void GetClientUniqueID()
{
    try
    {
        // Define the scope (namespace) to connect to.
        ManagementScope inventoryAgentScope = new ManagementScope(@"root\ccm");

        // Load the class to work with (CCM_Client).
        ManagementClass inventoryClass = new ManagementClass(inventoryAgentScope.Path.Path, "CCM_Client", null);

        // Query the class for the objects (create query, create searcher object, execute query).
        ObjectQuery query = new ObjectQuery("SELECT * FROM CCM_Client");
        ManagementObjectSearcher searcher = new ManagementObjectSearcher(inventoryAgentScope, query);
        ManagementObjectCollection queryResults = searcher.Get();

        // Loop through the available objects (only one) and display the ClientId value.
 
        foreach (ManagementObject result in queryResults)
        {
            Console.WriteLine("ClientId (GUID): " + result["ClientId"]);
        }
    }

    catch (System.Management.ManagementException ex)
    {
        Console.WriteLine("Failed to get client ID (GUID). Error: " + ex.Message);
        throw;
    }
}

Comments

Compiling the Code

This C# example requires:

Namespaces

System.Management

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.

See Also

Concepts

System Center Configuration Manager Software Development Kit
Configuration Manager Discovery
How to Call a WMI Class Method by Using System.Management