Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 获取设备的连接端口号和集线器号_Windows_Powershell - Fatal编程技术网

Windows 获取设备的连接端口号和集线器号

Windows 获取设备的连接端口号和集线器号,windows,powershell,Windows,Powershell,我使用以下命令获取连接的USB设备的设备信息 gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} | Sort Manufacturer,Description,DeviceID | Ft -GroupBy Manufacturer DeviceID 如何使用Windows Powershell获取设备的连接端口号和集线器号?您需要使用WMI列出USB设备ID,然后在注册表中查找每个ID以获取位置信息(如果存在) $device

我使用以下命令获取连接的USB设备的设备信息

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

如何使用Windows Powershell获取设备的连接端口号和集线器号?

您需要使用WMI列出USB设备ID,然后在注册表中查找每个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