How to Read a Configuration Manager Site Control File Embedded RegMultiString List
Updated: November 1, 2013
Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager
In System Center 2012 R2 Configuration Manager, you read an embedded RegMultiString list from a site control file component or configuration resource by getting the RegMultiStringList SMS_Client_Reg_MultiString_List object from the resources RegMultiStringLists property array.
To read a RegMultiString list
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Using the connection object from step one, get a site control file resource. For more information, see About the Configuration Manager Site Control File.
Get the SMS_Client_Reg_MultiString_List for the required RegMultiString list.
View the RegMultiString list values in the SMS_Client_Reg_MultiString_List ValueStrings array property.
Example
The following example method populates the supplied valueStrings parameter with the value strings of the embedded RegMultiString list identified by the valueName parameter. true is returned if the RegMultiString list is found; otherwise, false is returned.
You can update the embedded RegMultiString list returned from this method by using the method How to Write a Configuration Manager Site Control File Embedded RegMultiString List.
To view code that calls these methods, 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 GetScfRegMultiStringList(resource, _
valueName, _
ByRef valueString)
dim regMultiStringList
If IsNull(resource.RegMultiStringLists) = True Then
GetScfRegMultiStringList = false
Exit Function
End If
For Each regMultiStringList in resource.RegMultiStringLists
if UCase(regMultiStringList.ValueName) = UCase(valueName) Then
' Found the property, so populate values and exit.
valueName = regMultiStringList.ValueName
valueString = regMultiStringList.ValueStrings
GetScfRegMultiStringList = True
Exit Function
End If
Next
' Did not find the string list.
GetScfRegMultiStringList = False
End Function
public bool GetScfRegMultiStringList( IResultObject resource, string valueName, out ArrayList valueStrings) { valueStrings = new ArrayList(); try { if (resource.RegMultiStringLists.ContainsKey(valueName)) { valueStrings.AddRange(resource.RegMultiStringLists[valueName]["ValueStrings"].StringArrayValue); return true; } } catch (SmsException e) { Console.WriteLine("Couldn't get multi-string list: " + e.Message); } return false; }
Compiling the Code
The C# example has the following compilation requirements:
System
System.Collections.Generic
System.Collections
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
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.
About the Configuration Manager Site Control File
How to Read a Configuration Manager Site Control File Embedded Property
How to Read a Configuration Manager Site Control File Embedded Property List
How to Write a Configuration Manager Site Control File Embedded Property
How to Write a Configuration Manager Site Control File Embedded Property List
How to Write a Configuration Manager Site Control File Embedded RegMultiString List
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
The sample method has the following parameters:
Parameter
Type
Description
Resource
Managed: IResultObject
VBScript: SWbemObject
The site control file resource that contains the RegMultiString list.
ValueName
Managed: Integer
VBScript: Integer
The RegMultiString list name. It is obtained from the SMS_Client_Reg_MultiString_List class ValueName property.
ValueStrings
Managed: String
VBScript: String
The RegMultiString list. It is obtained from the SMS_Client_Reg_MultiString_List class ValueStrings property.