HolmesShelock Posted December 31, 2014 Share Posted December 31, 2014 My script goes like this: $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") $wmiQuery = "SELECT * FROM Win32_PnPEntity WHERE Name LIKE '%(COM%)'" $comPorts = $objWMIService.ExecQuery($wmiQuery, "WQL", 0) For $comPort in $comPorts ConsoleWrite("Name:" & $comPort.Name & ", HardwareID: " & $comPort.HardwareID & @CRLF) Next The output is this: Name:Device Diagnostic Interface (COM11), HardwareID: Name:Device Application Interface (COM12), HardwareID: Name:Device Pipe (COM10), HardwareID: The result returned by the same query triggered by WMIExplorer is this As you can see. my code snippet can access 'Name' field but fails to retrieve the values for 'HardwareID' field. Where am I going wrong? [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
Solution jguinch Posted December 31, 2014 Solution Share Posted December 31, 2014 Look at the Win32_PnPEntity help page : the HardwareID flied is an array. So try with this : ConsoleWrite("Name:" & $Name & ", HardwareID: " & $HardwareID[0] & @CRLF) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
HolmesShelock Posted December 31, 2014 Author Share Posted December 31, 2014 Look at the Win32_PnPEntity help page : the HardwareID flied is an array. Thanks a lot. I completely missed this part. [size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now