如何使用 WMI 读取延迟属性
若要从查询中返回的 Configuration Manager 对象读取惰性属性,请获取对象实例,该实例反过来又从 SMS 提供程序检索任何延迟对象属性。
注意
如果知道 WMI 对象的完整路径,则对 SWbemServices
类 Get
方法的调用将返回 WMI 对象以及任何延迟属性。 有关详细信息,请参阅如何使用 WMI 读取Configuration Manager对象。
有关延迟属性的详细信息,请参阅Configuration Manager延迟属性。
读取延迟属性
设置与 SMS 提供程序的连接。 有关详细信息,请参阅如何使用 WMI 连接到 Configuration Manager 中的 SMS 提供程序。
使用从步骤 1 获取的 SWbemServices 对象,使用 ExecQuery 对象查询Configuration Manager对象。
循环访问查询结果。
SWbemServices
使用从步骤 1 获取的对象,调用 Get 以获取要从中获取延迟属性的每个查询对象的 SWbemObject 对象。
示例
以下 VBScript 代码示例查询所有 SMS_Collection 对象,然后显示从 CollectionRules
惰性属性获取的规则名称。
有关调用示例代码的信息,请参阅调用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 中的短信提供程序
如何使用 WMI 创建Configuration Manager对象
如何使用 WMI 删除Configuration Manager对象
如何使用 WMI 修改Configuration Manager对象
如何使用 WMI 执行异步Configuration Manager查询
如何使用 WMI 执行同步Configuration Manager查询
如何使用 WMI 读取Configuration Manager对象