我试图按照使用WMI访问IIS 6的指南,但是我无法解决如何翻译SWbemServices的Get方法 ,因为Get-WmiObject似乎没有使用相同的path语法( 描述WMI对象 )。
我正在关注的示例位于连接到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'")
这首先取决于string是指一个对象还是一个类。
对象; 你可以把这个string转换成wmi 。
对于课程; 你可以把string转换成wmiclass 。
[wmi] 'root\MicrosoftIISv2:IIsWebVirtualDir="W3SVC/1/ROOT"' [wmiclass] 'root\MicrosoftIISv2:IIsWebVirtualDir'
WMI中的某些方法名称可能会从它们的wsh名称中更改,例如SpawnInstance_现在是CreateInstance , Put_只是Put 。
wmi是System.Management.ManagementObject的别名。
wmiclass是System.Management.ManagementClass的别名