共用方式為


如何使用 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 Instrumentation
Configuration Manager延遲屬性
物件概觀如何使用 WMI 呼叫Configuration Manager物件類別方法
如何使用 WMI 在 Configuration Manager 中連線到 SMS 提供者
如何使用 WMI 建立Configuration Manager物件
如何使用 WMI 刪除Configuration Manager物件
如何使用 WMI 修改Configuration Manager物件
如何使用 WMI 執行非同步Configuration Manager查詢
如何使用 WMI 執行同步Configuration Manager查詢
如何使用 WMI 讀取Configuration Manager物件