Question:
How can I get all USB ports and related details like port name, using Power Shell Script?
I tried Win32_USBControllerDevice class
. But did not get a port name.
Answer:
1 2 |
gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} |select name,description, deviceID, manufacturer | format-table -group by manufacturer |
Some explanation
The WMI class WIN32_USBControllerDevice
describes the connection between USB controllers (The Antecedent
) and their logical devices [CIM_LOGICALDEVICE]
(the Dependent
)
1 |
PS>gwmi Win32_USBControllerDevice |fl Antecedent,Dependent Antecedent : \\.\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086 &DEV_3A35&SUBSYS_02931028&REV_00\\3&172E68DD&0&E9" Dependent : \\.\root\cimv2:Win32_PnPEntity.DeviceID="USB\\ROOT_HUB\\4& 10B856B0&0" |
now you can check
win32_PnPEntity
to get more info about the device ex:
1 |
gwmi Win32_PnPEntity -Filter "DeviceID='USBSTOR\\DISK&..'" |