一台機器上可能有好幾個USB Port,當我們一但插入USB device的話,如何得知其USB format? USB的format如下:
PCIROOT(PciBusNumber)#PCI(PciDeviceNumber+PciFunctionNumber)#USBROOT(HubPortNumber)#USB(HubPortNumber[0].....#HubPortNumber[X])
Example: PCIROOT(0)#PCI(1D00)#USBROOT(0)#USB(1)#USB(8)
若不先得知USB的format,如何根據它來filter掉USB呢?所以這裡有一小段Sample Code可以輕易地得到USB的format。
cls $WmiNS = "root\standardcimv2\embedded" $Ports = Get-WmiObject -namespace $wmiNS -class USBF_PortInfo Echo "Total " $Ports.Count "USB Ports" #List all ports and attached device $Ports | Format-Table Port*, HasDeviceAttached, Device* |
Format-Table Port*: 會把在機器上所有USB Port的資訊秀出,像上面的example一樣。
HasDeviceAttached: 如果這個Port上面有USB插著的話,這邊會為1,沒有的話則為0。
Device*: 秀出有attached的USB DeviceClassID, DeviceVenderID, DeviceProductID。
文章標籤
全站熱搜
留言列表