B.1. Referencing an ObjectTo reference objects in WMI, you use a UNC-style path name. Here is an example of how to reference the C: drive on the host srv01: \\srv01\root\CIMv2:Win32_LogicalDisk.Device The first part of the path (\\srv01\) is a reference to the computer on which the object resides. To reference the computer on which the script is running, you can use a dot (.) for the computer name. The second part (root\CIMv2) is the namespace within which the object resides. Each WMI provider uses a unique namespace to store its associated objects. The third part (Win32_LogicalDisk) is the class of the object being referenced. The fourth part is the key/value pairs representing an object of that class. Generically, the path can be described as follows: \\ComputerName\NameSpace:ClassName.KeyName="KeyValue"[,KeyName2="KeyValue2"...] Now that we know how to reference WMI objects, let's access an object using VBScript's GetObject function. In order for GetObject to understand we are referencing WMI objects, we have to include one additional piece of information: the moniker. If you've done any Active Directory scripting before, you're probably familiar with the LDAP: and WinNT: monikers used in ADSI. For WMI, we need to use the winmgmts: moniker: set objDisk = GetObject("winmgmts:\\srv01" & _ "\root\CIMv2:" & _ "Win32_LogicalDisk.DeviceID='C:'") To accomplish the same thing in Perl, we need to use the Win32::OLE module. Here is the same code written in Perl: use Win32::OLE; $objDisk = Win32::OLE->GetObject("winmgmts:\\\\srv01" . "\\root\\CIMv2:" . "Win32_LogicalDisk.DeviceID='C:'"); |