共用方式為


如何讀取 Configuration Manager 控件檔案內嵌屬性清單

在 Configuration Manager 中,您可以從資源 PropLists 屬性陣列取得內嵌物件的SMS_EmbeddedPropertyList物件,以從月臺控制檔案資源讀取內嵌屬性清單。

內嵌屬性清單具有您可以設定的下列屬性。 如需詳細資訊, 請參閱 SMS_EmbeddedPropertyList

描述
PropertyListName 內嵌屬性名稱。
字串值的陣列。 每個數位專案都代表單一屬性清單專案。

注意

對月臺控制檔案進行變更可能會對 Configuration Manager 網站造成無法修復的損害。

讀取網站控制檔案內嵌屬性清單

  1. 設定與SMS提供者的連線。 如需詳細資訊,請 參閱SMS提供者基本概念

  2. 使用步驟 1 中的連線物件,取得月臺控制檔案資源。 如需詳細資訊,請參閱關於 Configuration Manager 月臺控制檔案

  3. SMS_EmbeddedPropertyList取得必要內嵌屬性清單的 。

  4. 使用物件 Values 屬性陣列來SMS_EmbeddedPropertyList存取屬性清單值。

範例

下列範例方法會在提供的values參數中填入 參數所識別之內嵌屬性清單SMS_EmbeddedPropertyListpropertyListNameValues 陣列。 true 如果找到內嵌屬性清單,則會傳回 ;否則會 false 傳回 。

若要檢視呼叫這些函式的程式代碼,請參閱 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

如需呼叫範例程式代碼的相關信息,請參閱呼叫 Configuration Manager 代碼段


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;

}

範例方法具有下列參數:

參數 Type 描述
Resource -管理: IResultObject
- VBScript: SWbemObject
包含內嵌屬性的月臺控制檔案資源。
propertyListName -管理: String
- VBScript: String
要讀取的內嵌屬性清單。
Values - Managed: String 陣列
- VBScript: String 陣列
Values SMS_EmbeddedProperty 類別屬性。 字串值的陣列。

正在編譯程式碼

C# 範例具有下列編譯需求:

命名空間

系統

System.Collections.Generic

System.Collections

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

組件

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

健全的程式設計

如需錯誤處理的詳細資訊,請參閱關於 Configuration Manager 錯誤

.NET Framework 安全性

如需保護 Configuration Manager 應用程式的詳細資訊,請參閱 Configuration Manager 角色型系統管理

另請參閱

關於 Configuration Manager 月臺控制檔案 如何使用 Managed 程式代碼讀取和寫入 Configuration Manager 月臺控制檔案如何使用 WMI 讀取和寫入 Configuration Manager 月臺控制檔案