Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to follow the guides for accessing IIS 6 using WMI but I'm having trouble working out how to translate the Get method of SWbemServices as Get-WmiObject doesn't seem to use the same path syntax (Describing the Location of a WMI Object).

The example I was following is located on Connecting to the WMI Provider:

' Method 1
set locatorObj = CreateObject("WbemScripting.SWbemLocator") 
set providerObj = locatorObj.ConnectServer("MyMachine", "root/MicrosoftIISv2") 
set nodeObj = providerObj.Get("IIsWebVirtualDir='W3SVC/1/Root'") 

' Method 2
set providerObj = GetObject("winmgmts://MyMachine/root/MicrosoftIISv2") 
set nodeObj = providerObj.get("IIsWebVirtualDir='W3SVC/1/ROOT'") 

' Method 3
set nodeObj = GetObject("winmgmts://MyMachine/root/MicrosoftIISv2:IIsWebVirtualDir='W3SVC/1/ROOT'") 
share|improve this question

This first depends upon whether the string refers to an object or a class.
For objects; you can cast the string to wmi.
For classes; you can cast the string to wmiclass.

[wmi] 'root\MicrosoftIISv2:IIsWebVirtualDir="W3SVC/1/ROOT"'
[wmiclass] 'root\MicrosoftIISv2:IIsWebVirtualDir'

Some method names in WMI might be changed from their wsh names, eg SpawnInstance_ is now CreateInstance and Put_ is just Put.

wmi is an alias for System.Management.ManagementObject.
wmiclass is an alias for System.Management.ManagementClass

See for an example.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.