次の方法で共有


WMI を使用して遅延プロパティを読み取る方法

クエリで返されたConfiguration Manager オブジェクトから遅延プロパティを読み取るには、オブジェクト インスタンスを取得します。これにより、SMS プロバイダーから遅延オブジェクト プロパティが取得されます。

注:

WMI オブジェクトへの完全なパスがわかっている場合は、クラス Get メソッドのSWbemServices呼び出しによって WMI オブジェクトと遅延プロパティが返されます。 詳細については、「WMI を使用してConfiguration Manager オブジェクトを読み取る方法」を参照してください。

遅延プロパティの詳細については、「遅延プロパティのConfiguration Manager」を参照してください。

遅延プロパティを読み取る

  1. SMS プロバイダーへの接続を設定します。 詳細については、「WMI を使用してConfiguration Managerで SMS プロバイダーに接続する方法」を参照してください。

  2. 手順 1 から取得した SWbemServices オブジェクトを使用して、ExecQuery オブジェクトを使用してオブジェクトConfiguration Manager照会します。

  3. クエリ結果を反復処理します。

  4. 手順 1 から取得した 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      

この例のメソッドには、次のパラメーターがあります。

パラメーター 説明
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 オブジェクトを読み取る方法