Enumerator object
Represents a stream of results returned from operations, such as a Pull operation. For example, the Session.Enumerate method returns multiple results.
Members
The Enumerator object has these types of members:
Methods
The Enumerator object has these methods.
Method | Description |
---|---|
ReadItem | Retrieves an item from the resource and returns an XML representation of the item. |
Properties
The Enumerator object has these properties.
Property | Description |
---|---|
AtEndOfStream |
Gets a Boolean value that indicates whether there are more items in the collection. |
Error |
Gets an XML representation of additional error information. |
Remarks
To start an enumeration, use Session.Enumerate. To do a WS-Enumeration:Pull operation that continues reading items in the enumeration, use Enumerator.ReadItem.
The Enumerator object corresponds to the IWSManEnumerator interface.
Examples
The following VBScript code example enumerates all the disks on a remote computer specified by the fully qualified domain name (servername.domain.com). The DisplayOutput subroutine formats the data output in the same way as the WinRM.cmd tool.
Option Explicit
Const RemoteComputer = "MIG50-64D.mig.net"
Dim objWsman, objSession, strResource
Dim objResultSet
Set objWsman = CreateObject( "WSMan.Automation" )
Set objSession = objWsman.CreateSession( "https://" _
& RemoteComputer )
strResource = "http://schemas.microsoft.com/wbem/wsman/1/" _
& "wmi/root/cimv2/Win32_OperatingSystem"
Dim iFlag
iFlag = objWsman.EnumerationFlagReturnObjectAndEPR or _
objWsman.EnumerationFlagHierarchyDeep
Set objResultSet = _
objSession.Enumerate( strResource, "", "", iFlag)
While Not objResultSet.AtEndOfStream
DisplayOutput( objResultSet.ReadItem )
Wend
'****************************************************
' Displays WinRM XML message using built-in XSL
'****************************************************
Sub DisplayOutput( strWinRMXml )
Dim xmlFile, xslFile
Set xmlFile = CreateObject( "MSXml2.DOMDocument.3.0" )
Set xslFile = CreateObject( "MSXml2.DOMDocument.3.0" )
xmlFile.LoadXml( strWinRMXml )
xslFile.Load( "WsmTxt.xsl" )
Wscript.Echo xmlFile.TransformNode( xslFile )
End Sub
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows Vista |
Minimum supported server |
Windows Server 2008 |
Header |
|
IDL |
|
Library |
|
DLL |
|