获取已连接 USB 设备的位置信息 [英] Getting location information of the connected USB device
本文介绍了获取已连接 USB 设备的位置信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
读取以下注册表项的powershell命令是什么?
what is the powershell command to read the following registry entry?
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_03A8&PID_0258\6&af75239&0&3\LocationInformation
我尝试了下面的代码,我以前只获取设备信息
I tried the following code, i used to get the Device information only
gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} |
Sort Manufacturer,Description,DeviceID |
Ft -GroupBy Manufacturer DeviceID
如何获取连接的USB设备的位置信息?
how to get the location information of the connected usb device?
推荐答案
你在寻找那个 :
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Enum\USB\VID_03F0&PID_1F1D\5&3aded796&0&2' -Name LocationInformation
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_03F0&PID_1F1D\5&3aded796&0&2
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_03F0&PID_1F1D
PSChildName : 5&3aded796&0&2
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
LocationInformation : Port_#0002.Hub_#0004
或
(Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Enum\USB\VID_03F0&PID_1F1D\5&3aded796&0&2' -Name LocationInformation).LocationInformation
Port_#0002.Hub_#0004
<小时>
您可以使用以下方法获取连接的设备:
You can get the connected devices using :
Get-WmiObject Win32_USBHub
<小时>
你只需要加入两个结果,例如我的硬盘:
You just need to join the two results for exemple for my hard drive :
$PnpdeviceId = (gwmi win32_USBHub | where { $_.name -like '*stockage*'}).PNPDeviceID
(Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$PnpdeviceId" -Name LocationInformation).LocationInformation
这篇关于获取已连接 USB 设备的位置信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文