Share via


Adding New Properties to an Existing Resource Type

When the Discovery Data Manager (DDM) detects that your DDR contains a property that does not exist in the resource class, the property is added to the resource class. Depending on the data type of the new property, previous instances of the resource will contain either a zero or an empty string ("") for the value of the new property. You should specify all the class properties when you update an existing resource class. However, do not include the seven properties that the DDM creates for you. For a list of the seven properties, see Creating a New Resource Class.

The following example creates a DDR that adds the OrganizationalUnit property to the SMS_R_System class. You can then use this property to create collections based on departments and distribute software accordingly. If your organization uses Active Directory, you can use the information it contains to populate the OrganizationalUnit property. The Active Directory/SMS Collection Synchronization Tools sample tool demonstrates this capability. You can download the tool at https://www.microsoft.com/smsmgmt/downloads.

This example shows you the key, name, and GUID properties that you use to update the system resource class. For more information on the use of the key, name , and GUID properties and the DDR functions, see Discovery Data Record Functions.

  [C/C++]
    DDRNew("System", "Department Discovery", "ABC");                   // SMS_R_System
    DDRAddString("Netbios Name", pszNetbios, 32, ADDPROP_NAME);        // update keys
    DDRAddStringArray("IP Addresses", paszIPAddrs, numIPAddrs, 21, ADDPROP_KEY);
    DDRAddStringArray("IPX Addresses", paszIPXAddrs, numIPXAddrs, 32, ADDPROP_KEY);
    DDRAddStringArray("MAC Addresses", paszMACAddrs, numMACAddrs, 64, ADDPROP_KEY);
    DDRAddStringArray("Resource Names", paszResNames, numResNames, 128, ADDPROP_KEY);
    DDRAddString("SMS Unique Identifier",
                 "GUID:12345678-1234-1234-1234-123456789012", 64,
                 ADDPROP_GUID | ADDPROP_KEY);
    DDRAddString("Organizational Unit", "Engineering", 64, 0);         // new property

    ...    // the rest of the system class properties

    DDRSendToSMS();
[Visual Basic]
    'The CStrings function in this example converts the array of variants
    'to an array of strings that the DDRAddStringArray function can use.

    Dim Resource As SWbemObject
    Dim DDR As New SMSResGen

    Set Resource = GetObject("winmgmts:root/sms/site_<sitecode>:SMS_R_System.ResourceID=<idvalue>")

    DDR.DDRNew "System", "Department Discovery", "<sitecode>"

    DDR.DDRAddInteger "Client", Resource.Client, ADDPROP_NONE
    DDR.DDRAddString "Client Version", Resource.ClientVersion, 15, ADDPROP_NONE
    DDR.DDRAddStringArray "IP Addresses", CStrings(Resource.IPAddresses), 64, ADDPROP_NONE
    DDR.DDRAddStringArray "IP Subnets", CStrings(Resource.IPSubnets), 64, ADDPROP_NONE
    DDR.DDRAddStringArray "IPX Addresses", CStrings(Resource.IPXAddresses), 21, ADDPROP_KEY
    DDR.DDRAddStringArray "IPX Network Numbers", CStrings(Resource.IPXNetworkNumbers), 32, ADDPROP_KEY
    DDR.DDRAddString "Last Logon User Domain", Resource.LastLogonUserDomain, 64, ADDPROP_NONE
    DDR.DDRAddString "Last Logon User Name", Resource.LastLogonUserName, 255, ADDPROP_NONE
    DDR.DDRAddStringArray "MAC Addresses", CStrings(Resource.MACAddresses), 64, ADDPROP_KEY
    DDR.DDRAddString "Netbios Name", Resource.NetbiosName, 32, ADDPROP_NAME
    DDR.DDRAddString "Operating System Name and Version", Resource.OperatingSystemNameandVersion, 64, ADDPROP_NONE
    DDR.DDRAddString "Resource Domain OR Workgroup", Resource.ResourceDomainORWorkgroup, 64, ADDPROP_NONE
    DDR.DDRAddStringArray "Resource Names", CStrings(Resource.ResourceNames), 128, ADDPROP_KEY
    DDR.DDRAddStringArray "SMS Installed Sites", CStrings(Resource.SMSInstalledSites), 3, ADDPROP_NONE
    DDR.DDRAddString "SMS Unique Identifier", Resource.SMSUniqueIdentifier, 64, ADDPROP_GUID And ADDPROP_KEY
    DDR.DDRAddStringArray "System Roles", CStrings(Resource.SystemRoles), 32, ADDPROP_NONE

    'The new property that is being added.
    DDR.DDRAddString "Organizational Unit", "<organizational unit>", 64, ADDPROP_NONE

    DDR.DDRSendToSMS

Note  In the example, the property names use spaces between the words. This is because the DDM concatenates SMS Unique Identifier to create the SMSUniqueIdentifier property name that you see in the class definition. You must specify the correct property name string to update instances in an existing resource class. Specifying SMSUniqueIdentifier instead of SMS Unique Identifier results in SMSUniqueIdentifier being added as a new property to SMS_R_System.

To ensure that you use the correct property name string, view the contents of the DiscPropertyDefs table in the SMS SQL Server database. Use the PropertyName value from the table for your property name string. The table also contains the MaxWidth value, which you use for the property's string length.

System resources use a GUID value for the unique identifier that is stored on the SMS client in the system registry. For information, see Getting the SMS Unique Identifier Value For a Client.