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.

MethodDescription
ReadItem

Retrieves an item from the resource and returns an XML representation of the item.

 

Properties

The Enumerator object has these properties.

PropertyDescription

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( "http://" _
    & 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

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Redistributable

WinRM 1.1 (Windows Server 2003 R2, Windows Server 2003 with SP1, or Windows XP with SP2)

Header

Wsmandisp.h

IDL

Wsmandisp.idl

Library

WSManAutomation.lib

DLL

Wsmauto.dll

See also

WinRM Scripting API
Enumerating or Listing All of the Instances of a Resource
Scripting in Windows Remote Management

 

 

Show:
© 2014 Microsoft. All rights reserved.