獲取

2013-07-25 122 views
3

我以前使用下面的命令獲取

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

得到連接的USB設備的設備信息如何獲得使用Windows PowerShell中的設備的連接的端口號和輪轂號連接的端口號和設備的集線器數量?

回答

1

你需要列出使用WMI,然後查找每個註冊表以獲取位置信息,如果存在的USB設備ID ...

$devices = gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)}|select DeviceID 
$devices.DeviceID | %{Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$_"}| 
select Mfg,DeviceDesc,HardwareID,LocationInformation,Class 

主要生產信息像這樣我的機器上:

Mfg     : @msmouse.inf,%msmfg%;Microsoft 
DeviceDesc   : @msmouse.inf,%hid.mousedevice%;HID-compliant mouse 
HardwareID   : {HID\VID_15CA&PID_00C3&REV_0512, HID\VID_15CA&PID_00C3, 
         HID_DEVICE_SYSTEM_MOUSE, HID_DEVICE_UP:0001_U:0002...} 
LocationInformation : 
Class    : Mouse 


Mfg     : @usb.inf,%generic.mfg%;(Standard USB Host Controller) 
DeviceDesc   : @usb.inf,%usb\composite.devicedesc%;USB Composite Device 
HardwareID   : {USB\VID_0408&PID_2FB1&REV_0901, USB\VID_0408&PID_2FB1} 
LocationInformation : Port_#0004.Hub_#0003 
Class    : USB