How to Read Lazy Properties by Using WMI
Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager
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.
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
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.
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 |
|
A valid connection to the SMS Provider. |
Compiling the Code
See Also
Windows Management Instrumentation
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