How to check for presence of hardware devices via WMI script (PnPEntity)

By | January 2, 2011
Share

In some cases devices are installed on some units and not others even within model groupings.  In my experience, I was looking to target certain Panasonic Toughbook laptops with Embedded Wireless cards installed to install the required software resources to address those needs.  Needless to say, the Wireless switches needed to switched to the “on” position for the OS to see the devices when the script was run.

See example script below to check for the presence of an AT&T Novatel EU860 module:

‘===================

‘ NAME:  PNPCheck.vbs

‘ AUTHOR: Brian Gonzalez
‘ DATE  : 4/5/2010

‘===================

If PNPCheck(“VID_1410&PID_2420”) Then ‘Novatel EU860 modem check
MsgBox(“ATT EU860 modem is present”)
End If

Function PNPCheck(DeviceName)
‘PNPID = “%VID_04DA&PID_250C%” ‘GOBI PNP ID
‘PNPID = “%VEN_1022&DEV_2000%” ‘VMWare NIC
Set objWMIService1 = GetObject(“winmgmts:\\.\root\CIMV2”)
Set colItems = objWMIService1.ExecQuery(“Select DeviceID FROM Win32_PnPEntity Where DeviceID LIKE “”%” & PnpID & “%”””)
If colItems.Count > 0 Then
PNPCheck = True
Else
PNPCheck = False
End If
End Function

2 thoughts on “How to check for presence of hardware devices via WMI script (PnPEntity)

  1. Tim

    Sorry for necro-posting but your code is incorrect.
    Where DeviceID LIKE “”%” & PnpID & “%”””)
    Should be:
    Where DeviceID LIKE “”%” & DeviceName & “%”””)

    The device id when passed to the PNPCheck function is called DeviceName not PnpID .

    Reply
  2. Tim

    Where DeviceID LIKE “”%” & PnpID & “%”””
    should be
    Where DeviceID LIKE “”%” & DeviceName & “%”””

    Reply

Leave a Reply

Your email address will not be published.

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.