# From the book "Windows XP Cookbook" # ISBN: 0596007256 # Note that you cannot use this to connect to the local machine. # ------ SCRIPT CONFIGURATION ------ use Win32::OLE; $strServer = ''; # e.g. wks01 $strUser = ''; # e.g. AMER\rallen.adm $strPasswd = ''; # ------ END CONFIGURATION --------- $objLocator = Win32::OLE->new('WbemScripting.SWbemLocator'); $objWMI = $objLocator->ConnectServer($strServer, 'root\\cimv2', $strUser, $strPasswd); if ((0 + Win32::OLE::LastError()) != 0) { print 'Authentication failed: ' . ('' . Win32::OLE::LastError()), "\n"; } # Now you can use the objWMI object to get an instance of a class # or perform a WQL query. Here is an example: $colDisks = $objWMI->InstancesOf('Win32_LogicalDisk')->Item;