Created
June 4, 2016 21:23
-
-
Save bryder/f79b3c059fa571841e20f6d42d22289d to your computer and use it in GitHub Desktop.
get vid and pids from windows usb list in poweshell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$usb_devices = gwmi Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | where {( $_.Description -match "storage" -or $_.Description -match "usb") -and $_.Description -notmatch "hub"} | |
$regex = '.*VID_(?<vid>[0-9A-F]{4})&PID_(?<pid>[0-9A-F]{4}).*' | |
$usb_devices | foreach { if ($_.deviceid -match $regex) { add-member -inputobject $_ @{VID=$matches['vid']; PID=$matches['pid']} -passthru } else { $_ }} | sort pnpclass,name | ft Name, manufacturer, pnpclass, deviceid, vid, pid | |
# some variatinos on select the devices | |
$usb_devices = gwmi Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | where {( $_.Description -match "storage" -or $_.Description -match "usb") -and $_.Description -notmatch "hub"} | |
$usb_devices = gwmi Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | where { $_.Description -notmatch "hub"} | |
$usb_devices = gwmi Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment