How to Read a Configuration Manager Site Control File Embedded Property List

In System Center Configuration Manager, you read an embedded property list from a site control file resource by getting the SMS_EmbeddedPropertyList object for the embedded object from the resources PropLists property array.

An embedded property list has the following properties that you can set. For more information, see SMS_EmbeddedPropertyList.

Value Description
PropertyListName The embedded property name.
Values An array of string values. Each array item represents a single property list item.

Caution

Making changes to the site control file can cause irreparable damage to your System Center Configuration Manager site.

To read a site control file embedded property list

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Using the connection object from step one, get a site control file resource. For more information, see About the Configuration Manager Site Control File.

  3. Get the SMS_EmbeddedPropertyList for the required embedded property list.

  4. Access the property list values by using the SMS_EmbeddedPropertyList object Values property array.

Example

The following example method populates the supplied values parameter with the Values array of the embedded property list SMS_EmbeddedPropertyList identified by the propertyListName parameter. true is returned if the embedded property list is found; otherwise, false is returned.

To view code that calls these functions, see How to Read and Write to the Configuration Manager Site Control File by Using Managed Code or see How to Read and Write to the Configuration Manager Site Control File by Using WMI.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.


Function GetScfEmbeddedPropertyList(resource,  _  
        propertyListName,               _  
        ByRef values)  

    Dim scfPropertyList  

    If IsNull(resource.PropLists) = True Then  
        GetScfPropertyList = False  
        Exit Function  
    End If      

    For each scfPropertyList in resource.PropLists  
       if   scfPropertyList.PropertyListName = propertyListName Then  
            ' Found property list, so return the values array.  
            values = scfPropertyList.Values  
            GetScfEmbeddedPropertyList = True  
            Exit Function  
        End If  
     Next    

     ' Did not find the property list.  
     GetScfEmbeddedPropertyList = False  
End Function  
public bool GetScfEmbeddedPropertyList(  
    IResultObject resource,  
    string propertyListName,  
    out ArrayList values)  
{  
    values = new ArrayList();  
    try  
    {  
        if (resource.EmbeddedPropertyLists.ContainsKey(propertyListName))  
        {  
            values.AddRange(resource.EmbeddedPropertyLists[propertyListName]["Values"].StringArrayValue);  
            return true;  
        }  
    }  
    catch(SmsException e)  
    {  
        Console.WriteLine("Couldn't get the embedded property list: " + e.Message);  
    }  
    return false;  

}  

The sample method has the following parameters:

Parameter Type Description
Resource - Managed: IResultObject
- VBScript: SWbemObject
The site control file resource that contains the embedded property.
propertyListName - Managed: String
- VBScript: String
The embedded property list to be read.
Values - Managed: String array
- VBScript: String array
The SMS_EmbeddedProperty class Values property. An array of string values.

Compiling the Code

The C# example has the following compilation requirements:

Namespaces

System

System.Collections.Generic

System.Collections

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

Robust Programming

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

.NET Framework Security

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

See Also

About the Configuration Manager Site Control File
How to Read and Write to the Configuration Manager Site Control File by Using Managed Code
How to Read and Write to the Configuration Manager Site Control File by Using WMI