Created
December 14, 2022 21:12
-
-
Save awakecoding/5fb42c3ea06f35134c7125267630c09c to your computer and use it in GitHub Desktop.
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
# Enumerate RDP USB devices like mstsc does | |
$RdpUsbDeviceExcludedClassGuids = @( | |
'{4d36e96b-e325-11ce-bfc1-08002be10318}', # Keyboard | |
'{4d36e972-e325-11ce-bfc1-08002be10318}', # Net | |
'{4d36e968-e325-11ce-bfc1-08002be10318}', # Display | |
'{4d36e967-e325-11ce-bfc1-08002be10318}', # DiskDrive | |
'{4d36e965-e325-11ce-bfc1-08002be10318}', # CDROM | |
'{e0cbf06c-cd8b-4647-bb8a-263b43f0f974}', # Bluetooth | |
'{745a17a0-74d3-11d0-b6fe-00a0c90f57da}', # HIDClass | |
#'{ca3e7ab9-b4c3-4ae6-8251-579ef933890f}', # Webcam | |
'{36fc9e60-c465-11cf-8056-444553540000}' # USB | |
) | |
Get-CimInstance -ClassName Win32_PnpEntity -Namespace 'root\CIMV2' -Filter "PNPDeviceId like 'USB\\%' and Status like 'OK'" | | |
Where-Object { -Not $RdpUsbDeviceExcludedClassGuids.Contains($_.ClassGuid) } | | |
Select-Object -Property @{ | |
N = 'BusDescription' | |
E = { | |
$params = @{ | |
MethodName = 'GetDeviceProperties' | |
Arguments = @{ | |
devicePropertyKeys = @('DEVPKEY_Device_BusReportedDeviceDesc') | |
} | |
} | |
$res = $_ | Invoke-CimMethod @params | |
$res.deviceProperties[0].Data | |
} | |
}, PNPDeviceID, ClassGuid | |
# BusDescription PNPDeviceID ClassGuid | |
# -------------- ----------- --------- | |
# FingerPrint USB\VID_27C6&PID_533C\5&338395B4&0&1 {53d29ef7-377c-4d14-864b-eb3a85769359} | |
# Generic Billboard Device USB\VID_1D5C&PID_7102\5&338395B4&0&2 {88bae032-5a81-49f0-bc3d-a4ff138216d6} | |
# YubiKey OTP+FIDO+CCID USB\VID_1050&PID_0407&MI_02\6&5A35C8D&0&0002 {50dd5230-ba8a-11d1-bf5d-0000f805f530} | |
# Integrated Webcam USB\VID_0C45&PID_6D14&MI_02\6&4B5DF06&0&0002 {ca3e7ab9-b4c3-4ae6-8251-579ef933890f} | |
# Integrated Webcam USB\VID_0C45&PID_6D14&MI_00\6&4B5DF06&0&0000 {ca3e7ab9-b4c3-4ae6-8251-579ef933890f} | |
# USB-C to DisplayPort Cable in 4K 60Hz USB\VID_0BDA&PID_5442\123456789ABCDEFGH {88bae032-5a81-49f0-bc3d-a4ff138216d6} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment