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

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

注:

WMI オブジェクトへの完全なパスがわかっている場合、 SWbemServices クラス Get メソッドを呼び出すと、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 オブジェクトに対してクエリを実行し、 CollectionRules lazy プロパティから取得したルール名を表示します。

サンプル コードの呼び出しの詳細については、「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 オブジェクトを読み取る方法