Partilhar via


How to Read Lazy Properties by Using WMI

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

To read a lazy property from a Microsoft System Center Configuration Manager 2007 object returned in a query, you get the object instance, which in turn retrieves any lazy object properties from the SMS Provider.

Note

If you know the full path to the WMI object, a call to the SWbemServices class Get method will return the WMI object along with any lazy properties. For more information, see How to Read a Configuration Manager Object by Using WMI.

For more information about lazy properties, see Configuration Manager Lazy Properties.

To read lazy properties

  1. Set up a connection to the SMS Provider. For more information, see How to Connect to an SMS Provider in Configuration Manager by Using WMI.

  2. Using the SWbemServices object you obtain from step one, use the ExecQuery object to query Configuration Manager 2007 objects.

  3. Iterate through the query results.

  4. Using the SWbemServices object you obtain from step one, call Get to get the SWbemObject object for each queried object you want to get lazy properties from.

Example

The following VBScript code example queries for all SMS_Collection objects and then displays rule names obtained from the CollectionRules lazy property.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

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    

This example method has the following parameters:

Parameter Type Description

connection

  • SWbemServices

A valid connection to the SMS Provider.

Compiling the Code

See Also

Concepts

Configuration Manager Lazy Properties
Configuration Manager Objects Overview
How to Call a Configuration Manager Object Class Method by Using WMI
How to Connect to an SMS Provider in Configuration Manager by Using WMI
How to Create a Configuration Manager Object by Using WMI
How to Delete a Configuration Manager Object by Using WMI
How to Modify a Configuration Manager Object by Using WMI
How to Perform an Asynchronous Configuration Manager Query by Using WMI
How to Perform a Synchronous Configuration Manager Query by Using WMI
How to Read a Configuration Manager Object by Using WMI
How to Use Configuration Manager Objects with WMI

Other Resources

https://go.microsoft.com/fwlink/?LinkId=43950