Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 11

WMI monitor looking at USB hardware and reporting back status and what usb device name

I need advice on building a WMI monitor script to monitor the status of USB ports and if there is something attached and report back on it.

so confused !

0 Kudos
1 Reply

Wmi and usb are pretty ugly to query, its not like a switch where you can just say, list off all my ports and tell me if something is plugged into it.  Your machine will typically have a couple usb controllers, some internal, some external, and since USB allows daisy chained devices there isn't exactly a 1 to 1 relationship between physical slots on your workstation and usb devices that come back as connected.

I found this powershell that queries wmi and generates a report of connected devices, but it would need a LOT of cleanup to be able to be used as a component in SAM.

gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} | Sort Manufacturer,Description,DeviceID | Ft -GroupBy Manufacturer Description,Service,DeviceID

This is the kind of output it gives back:

Manufacturer: (Standard keyboards)

Description         Service DeviceID                                    

-----------         ------- --------                                    

HID Keyboard Device kbdhid  HID\VID_046D&PID_C52B&MI_00\7&1218A125&0&0000

   Manufacturer: (Standard system devices)

Description                         Service DeviceID                                          

-----------                         ------- --------                                          

HID-compliant system controller             HID\VID_046D&PID_C52B&MI_01&COL03\7&1177B19&0&0002

HID-compliant vendor-defined device         HID\VID_046D&PID_C52B&MI_01&COL04\7&1177B19&0&0003

HID-compliant vendor-defined device         HID\VID_046D&PID_C52B&MI_02&COL01\7&14479757&0&0000

HID-compliant vendor-defined device         HID\VID_046D&PID_C52B&MI_02&COL02\7&14479757&0&0001

HID-compliant vendor-defined device         HID\VID_046D&PID_C52B&MI_02&COL03\7&14479757&0&0002

USB Input Device                    HidUsb  USB\VID_046D&PID_C52B&MI_01\6&95DED89&0&0001      

USB Input Device                    HidUsb  USB\VID_046D&PID_C52B&MI_02\6&95DED89&0&0002      

   Manufacturer: (Standard USB Host Controller)

Description                                           Service DeviceID                          

-----------                                           ------- --------                          

Unknown USB Device (Device Descriptor Request Failed)         USB\VID_0000&PID_0002\5&7C6516D&0&2

USB Composite Device                                  usbccgp USB\VID_046D&PID_C52B\5&7C6516D&0&4

USB Composite Device                                  usbccgp USB\VID_174F&PID_2409\5&7C6516D&0&5

   Manufacturer: (Standard USB HUBs)

Description         Service DeviceID                    

-----------         ------- --------                    

USB Root Hub (xHCI) USBHUB3 USB\ROOT_HUB30\4&1FC3C7B2&0&0

   Manufacturer: DMAX-AVC

Description Service    DeviceID                                   

----------- -------    --------                                   

EasyCamera  SNP2UVCW10 USB\VID_174F&PID_2409&MI_00\6&F78FF57&0&0000

   Manufacturer: Logitech (x64)

Description               Service DeviceID                                   

-----------               ------- --------                                   

Logitech USB Input Device HidUsb  USB\VID_046D&PID_C52B&MI_00\6&95DED89&0&0000

   Manufacturer: Microsoft

Description                                                Service    DeviceID                                                                                               

-----------                                                -------    --------                                                                                               

AV Remote Target Service                                              BTHENUM\{0000110C-0000-1000-8000-00805F9B34FB}_VID&00010039_PID&1582\7&35E9B622&0&001167BDAB1C_C00000000

Bluetooth Audio/Video Remote Control HID                   BthAvrcpTg BTHENUM\{0000110E-0000-1000-8000-00805F9B34FB}_VID&00010039_PID&1582\7&35E9B622&0&001167BDAB1C_C00000000

Bluetooth Device                                                      BTHENUM\DEV_001167BDAB1C\7&35E9B622&0&BLUETOOTHDEVICE_001167BDAB1C                                     

Bluetooth Device (Personal Area Network)                   BthPan     BTH\MS_BTHPAN\6&158B9721&0&2                                                                           

Bluetooth Device (RFCOMM Protocol TDI)                     RFCOMM     BTH\MS_RFCOMM\6&158B9721&0&0                                                                           

Bluetooth Hands-Free                                       BthHFAud   BTHHFENUM\BTHHFPAUDIO\8&305BF65B&0&97                                                                  

Bluetooth Hands-Free Audio and Call Control HID Enumerator BthHFEnum  BTHENUM\{0000111E-0000-1000-8000-00805F9B34FB}_VID&00010039_PID&1582\7&35E9B622&0&001167BDAB1C_C00000000

Bluetooth Hands-Free Call Control HID                      bthhfhid   BTHHFENUM\BTHHFPHID\8&305BF65B&0&104                                                                   

Bluetooth Stereo                                           BthA2DP    BTHENUM\{0000110B-0000-1000-8000-00805F9B34FB}_VID&00010039_PID&1582\7&35E9B622&0&001167BDAB1C_C00000000

HID-compliant consumer control device                                 HID\VID_046D&PID_C52B&MI_01&COL02\7&1177B19&0&0001                                                     

HID-compliant mouse                                        mouhid     HID\VID_046D&PID_C52B&MI_01&COL01\7&1177B19&0&0000                                                     

Microsoft Bluetooth Enumerator                             BthEnum    BTH\MS_BTHBRB\6&158B9721&0&1                                                                           

Microsoft Bluetooth LE Enumerator                          BthLEEnum  BTH\MS_BTHLE\6&158B9721&0&0                                                                            

   Manufacturer: Qualcomm Atheros Communications

Description                            Service DeviceID                          

-----------                            ------- --------                          

Qualcomm Atheros QCA61x4 Bluetooth 4.1 BTHUSB  USB\VID_0CF3&PID_E300\5&7C6516D&0&7

   Manufacturer: Synaptics Incorporated

Description    Service DeviceID                         

-----------    ------- --------                         

Synaptics WBDI WUDFRd  USB\VID_138A&PID_0094\6EFE8CB954D2

- Marc Netterfield, Github