共用方式為


如何使用 WMI 讀取延遲屬性

若要從查詢中傳回的 Configuration Manager 物件讀取延遲屬性,您會取得 對象實例,該實例接著會從 SMS 提供者擷取任何延遲物件屬性。

注意事項

如果您知道 WMI 物件的完整路徑,呼叫 SWbemServices 類別 Get 方法會傳回 WMI 物件以及任何延遲屬性。 如需詳細資訊,請參閱如何使用WMI讀取 Configuration Manager 物件

如需延遲屬性的詳細資訊,請參閱 Configuration Manager 延遲屬性。

讀取延遲屬性

  1. 設定與SMS提供者的連線。 如需詳細資訊,請參閱 How to Connect to an SMS Provider in Configuration Manager by Using WMI

  2. 使用您從步驟一取得的 SWbemServices 物件,使用 ExecQuery 對象來查詢 Configuration Manager 物件。

  3. 逐一查看查詢結果。

  4. SWbemServices使用您從步驟一取得的物件,呼叫 Get 以取得您想要從中取得延遲屬性之每個查詢物件的 SWbemObject 物件。

範例

下列 VBScript 程式代碼範例會查詢所有 SMS_Collection 對象,然後顯示從 lazy 屬性取得的 CollectionRules 規則名稱。

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

Sub ReadLazyProperty(connection)

    Dim collection
    Dim collections
    Dim collectionLazy
    Dim i

    ' Get all collections.
    Set collections = _
        connection.ExecQuery("Select * From SMS_Collection")

    For Each collection in collections

        Wscript.Echo Collection.Name

        ' Get the collection object.
        Set collectionLazy = connection.Get("SMS_Collection.CollectionID='" + collection.CollectionID + "'")

        ' Display the rule names that are in the lazy property CollectionRules.
        If IsNull(collectionLazy.CollectionRules) Then
            Wscript.Echo "No rules"
        Else
            For i = 0 To UBound(collectionLazy.CollectionRules)
                WScript.Echo "Rule " + collectionLazy.CollectionRules(i).RuleName
            Next
       End If
    Next

End Sub

此範例方法具有下列參數:

參數 Type 描述
connection - SWbemServices SMS 提供者的有效連線。

正在編譯程式碼

另請參閱

Windows Management InstrumentationConfiguration Manager Lazy 屬性物件概觀如何使用 WMI 如何使用 WMI 如何使用 WMI 如何在 Configuration Manager 中聯機至 SMS 提供者來呼叫 Configuration Manager 物件類別方法如何建立Configuration Manager 物件使用 WMI如何使用 WMI 如何使用 WMI 修改 Configuration Manager 物件如何執行異步 Configuration Manager 查詢來刪除 Configuration Manager 物件使用 WMI如何使用 WMI 如何使用 WMI 讀取 Configuration Manager 物件來執行同步 Configuration Manager 查詢