To read a lazy property from a System Center 2012 R2 Configuration Manager object returned in a query, you get the object instance, which in turn retrieves any lazy object properties from the SMS Provider.
|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
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.
Using the SWbemServices object you obtain from step one, use the ExecQuery object to query System Center 2012 R2 Configuration Manager objects.
Iterate through the query results.
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.
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.
|Visual Basic Script||Copy Code|
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:
A valid connection to the SMS Provider.
Compiling the Code
TasksHow 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
ConceptsConfiguration Manager Lazy Properties
Configuration Manager Objects Overview
How to Use Configuration Manager Objects with WMI