What is the WMI / WQL Query syntax to get all devices connected to a specific USB Hub?
I can open up a PS terminal and enumerate all USB Hub Devices, as such:
gwmi Win32_UsbHub | fl *
The output will return a list of all USB Hub device on the system. Here is a sampling of one such device.
Device ID: USB\VID_0451&PID_DD01\6&16FAF918&1&2, PNP Device ID: USB\VID_0451&PID_DD01\6&16FAF918&1&2, Description: Generic SuperSpeed USB Hub Availability Caption=Generic SuperSpeed USB Hub ClassCode ConfigManagerErrorCode=0 ConfigManagerUserConfig=False CreationClassName=Win32_USBHub CurrentAlternateSettings CurrentConfigValue Description=Generic SuperSpeed USB Hub DeviceID=USB\VID_0451&PID_DD01\6&16FAF918&1&2 ErrorCleared ErrorDescription GangSwitched InstallDate LastErrorCode Name=Generic SuperSpeed USB Hub NumberOfConfigs NumberOfPorts PNPDeviceID=USB\VID_0451&PID_DD01\6&16FAF918&1&2 PowerManagementCapabilities PowerManagementSupported ProtocolCode Status=OK StatusInfo SubclassCode SystemCreationClassName=Win32_ComputerSystem SystemName=JMR-ENG-SARAH USBVersion
Using say the PNPDeviceID
for this hub, I would like to get all connected devices, if any to it.
I am totally green with PS and WMI, but I thought of using ASSOCIATES OF
as follows:
Get-WmiObject Win32_PnPEntity | select "ASSOCIATORS OF {Win32_UsbHub.DeviceID='USB\VID_0451&PID_DD01\6&16FAF918&1&2'}"
Annoyingly, enumerations do not list parent and children, though Device Manager does list things nicely and has a Parent.
Maybe just the way that I phrased things. Many other ways threw an error, so I did research and saw this syntax. I originally thought of using a gwmi
command. In any event, I know from Device Manager
that there are connected devices, but the above command yielded a blank screen.
WMI Explorer
was not much help.
What would be the SELECT
statement to use?