Installing Applications based on Hardware Present on Device Using WMI Queries

As you may or may not know, MDT has an excellent feature where you can add basic if conditions to a task sequence’s steps. This comes in really handy for specific application installs as you can add these if conditions to those installs based on the presence of certain things such as task sequence variables or better yet, specific hardware queries.

I’ve known for sometime now that this was possible due to this post from Andrew “Scriptimus” Barnes.

Unfortunately, I’m nowhere near an expert on WMI and WQL queries, so I just left it alone for a while. Until I finally got tired of installing a certain program by hand on the roughly 20% of PCs in my environment that need it. Thankfully this program only needs to be installed on PCs that have a specific USB device attached.

Started googling around and then stumbled across this, that I realized that for a USB device, ‘Win32_PNPEntity’ is what I would need to query.

See, if you need program X installed when and only when USB hardware Y is present, MDT can do that, it’s just a matter of writing the correct WMI query. Here’s what worked for me after more trial and error than I’d like to admit.

Get the Hardware ID from device manager. In this case, it’s a USB device. So when I add the If statement, use the PNPEntity and the correct DeviceID

Namespace: root\cimv2
Query: Win32_PNPEntity WHERE DeviceID LIKE ‘%VID_123A&PID_1000%’

Conditional

Your mileage may vary. Just make sure the Device ID matches what’s in the Device Manager.

Advertisements