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

  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 System Center 2012 R2 Configuration Manager 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.

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:

Parameter Type Description

connection

  • SWbemServices

A valid connection to the SMS Provider.

Compiling the Code

See Also