Convert Powershell WMI to relevance

So, I know I can’t do

Exists Get-WmiObject Win32_USBControllerDevice -ErrorAction Stop | ForEach-Object { wmi } | Where-Object { $.name -like “Displaylink*” -or $.name -like “ThinkPad USBdock” -or $.DeviceID -like “usb\vid_17ef&pid_1010” -or $.DeviceID -like “usb\vid_17ef&pid_1012” }

But any ideas? The biggest hurtle is the .dependent fields have the data we want.

I’m trying to create a relevance to see if a computer is in its dock. The specific reg keys i’ve found on the internet don’t work right as my desktop and my laptop have the same key but the desktop isn’t in a dock…

but that WMI query if it comes back with anything means the computer is in a dock. But if it returns nothing it means the computer isn’t in a dock.

Did you mean?

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\IDConfigDB\CurrentDockInfo\DockingState

What value are you getting? 1 should be not docked and 2 should be docked

For the WMI try this.

exists string values of selects “ChassisTypes from Win32_SystemEnclosure” of wmi

1 Like

Bigfix also supports the DMI and SMBIOS inspectors, you can check if there is a computer’s dmi, or smbios, returning the information that you need. Here are a couple of examples of Bigfix inspectors

Q: names of values of structures “system_slots” of smbios
Q: description_strings of on_board_devices_informations of dmi

For the reg key, my laptop is in a dock but it is still only 1 not 2. So that doesn’t work. The other issue with using Chassistypes is with lenovo laptops Chassistypes only comes up with “10”. for my computer which is in a dock. Per the documentation it should show up as 12. But it doesn’t. So I don’t know if Lenovo’s implementation is incorrect or something else is wrong.

I did look at these items and nothing came up glaring to me pointing out its a dock. I think its treated as a USB accessory which is possible limiting what I can query for.

I am not sure if your method will work, but I would like to show how to convert that piped WMI method into relevance. Perhaps it will inspire a full solution to your “is it docked” requirement.

Start with
q: selects "* from Win32_USBControllerDevice" of wmi

You already mentioned the Dependent property is the one of interest, so,

q: selects "Dependent from Win32_USBControllerDevice" of wmi
A: Dependent=\\LP1-US-51819475\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB30\\4&20859DE9&0&0"
A: Dependent=\\LP1-US-51819475\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_06CB&PID_009A\\1EC0B486C74B

We are interested in the values, so

q: string values of selects "Dependent from Win32_USBControllerDevice" of wmi
A: \\LP1-US-51819475\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB30\\4&20859DE9&0&0"
A: \\LP1-US-51819475\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_06CB&PID_009A\\1EC0B486C74B"

Then we can use a Whose clause to filter only the ones that have your 3 criteria strings.

q: string values whose (it contains "Displaylink" or it contains "ThinkPad USBdock" or it contains "usb\\vid_17ef&pid_1010" or it contains "usb\\vid_17ef&pid_1012") of selects "Dependent from Win32_USBControllerDevice" of wmi

(I have none of those, since I am not on a dock)

And then toss an exists in front of it all, for:

q: exists string values whose (it contains "Displaylink" or it contains "ThinkPad USBdock" or it contains "usb\\vid_17ef&pid_1010" or it contains "usb\\vid_17ef&pid_1012") of selects "Dependent from Win32_USBControllerDevice" of wmi
A: False
2 Likes

Hi, That worked with one slight modification.

q: exists string values whose (it contains “Displaylink” or it contains “ThinkPad USBdock” or it contains “USB\VID_17EF&PID_1010” or it contains “USB\VID_17EF&PID_1012”) of selects “Dependent from Win32_USBControllerDevice” of wmi
A: True

I had to capitalize the VID pieces as I couldn’t seem to use as string as lower case in any fashion. :slight_smile: But regardless Thanks for all your help!

1 Like

You can “as lowercase” each it, or you can cast the String Value

q: exists (string values of it as lowercase) whose (it contains "displaylink" or it contains "thinkpad usbdock" or it contains "usb\\vid_17ef&pid_1010" or it contains "usb\\vid_17ef&pid_1012") of selects "Dependent from Win32_USBControllerDevice" of wmi