I am using a WMI query as part of a general diagnostic script, and I query the following:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_PnPEntity",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_PnPEntity instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "ClassGuid: " & objItem.ClassGuid
Wscript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
Wscript.Echo "Service: " & objItem.Service
Wscript.Echo "Status: " & objItem.Status
Next
Whenever I run this on a workstation with PS/2 ports, I get that both a PS/2 Keyboard and Mouse (not present) are showing the error code for [Not Present, Not Working, No Driver Installed].
Is there any way to differentiate this from other devices that are actually failed? I'd like to still show PS/2 Errors, if possible, but dont see what I could use to separate these from the real entries.
The Win32_PnPEntity WMI class represents the properties of a Plug and Play device.
The PS/2 interface dates from 1987, before there was such a thing as plug and play.
That said, take a look at the class definition linked above. The Availability and the ConfigManagerErrorCode members break it down into pretty granular status codes. Perhaps they can be of some use to you in differentiating your PS/2 devices. (Which you might be doing already.) You can also try cross-referencing that data with Win32_PointingDevice and Win32_Keyboard. Makes your job harder but that's probably the best you'll get from WMI.