ResourceLocator object

An object that supplies the path to a resource. You can use a ResourceLocator object instead of a resource URI in Session object operations such as Session.Get, Session.Put, or Session.Enumerate.

This object enables you to:

  • Add one or more selectors that identify a particular instance of a resource. This is the same as supplying a key value in the resource URI for a resource that uses keys. For more information, see ResourceLocator.AddSelector. You can do a similar operation using the filter parameter in a call to Session.Enumerate.
  • Specify a fragment path and dialect to get only one property of a resource. You can also specify one or all of the elements of an array property by supplying the array index. For more information, see ResourceLocator.FragmentPath.
  • Add one or more options that a data source may require to process a request. For more information, see ResourceLocator.AddOption.
For more information, see Querying for Specific Instances of a Resource.

Members

The ResourceLocator object has these types of members:

Methods

The ResourceLocator object has these methods.

MethodDescription
AddOption

Adds additional data required to process the request.

AddSelector

Adds a selector to the ResourceLocator object.

ClearOptions

Removes any options from the ResourceLocator object.

ClearSelectors

Removes all the selectors from a ResourceLocator object.

 

Properties

The ResourceLocator object has these properties.

PropertyAccess typeDescription

FragmentDialect

Read/write

Gets or sets the language dialect for a resource fragment.

FragmentPath

Read/write

Gets or sets the path for a resource fragment or property.

MustUnderstandOptions

Read/write

Gets or sets the MustUnderstandOptions value for the ResourceLocator object.

ResourceURI

Read/write

Gets or sets the resource URI in a ResourceLocator object.

 

Remarks

The ResourceLocator object corresponds to the IWSManResourceLocator interface.

Examples

The following VBScript code example obtains the NumberOfLogicalProcessors and NumberOfCores properties from a specific instance of Win32_Processor.


Option Explicit
Dim strUri
strUri = "http://schemas.microsoft.com/wbem/wsman/1/" _
    & "wmi/root/cimv2/Win32_Processor"
Const FragmentDialect = _
    "http://www.w3.org/TR/1999/REC-xpath-19991116"

Dim WSMan
Set WSMan = CreateObject("WSMan.Automation")

Dim Session
Set Session = WSMan.CreateSession

Dim Locator
Set Locator = WSMan.CreateResourceLocator(strUri)

Locator.AddSelector "DeviceID", "CPU0"

Dim NumberOfCores_XML
Locator.FragmentPath = "NumberOfCores"
Locator.FragmentDialect = FragmentDialect
NumberOfCores_XML = Session.Get(Locator)
DisplayOutput NumberOfCores_XML

Dim NumberOfLogicalProcessors_XML
Locator.FragmentPath = "NumberOfLogicalProcessors"
Locator.FragmentDialect = FragmentDialect
NumberOfLogicalProcessors_XML = Session.Get(Locator)

DisplayOutput NumberOfLogicalProcessors_XML

'****************************************************
' 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

Minimum supported server

Windows Server 2008

Header

WSManDisp.h

IDL

WSManDisp.idl

Library

WSManDisp.tlb

DLL

WSMAuto.dll

See also

WinRM Scripting API

 

 

Show: