你需要列出使用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