param([string]$Match = 'vid_320f&pid_502a') Add-Type @" using System; using System.Runtime.InteropServices; using System.Text; public static class H { [StructLayout(LayoutKind.Sequential)] public struct CAPS { public ushort Usage, UsagePage, InLen, OutLen, FeatLen; [MarshalAs(UnmanagedType.ByValArray, SizeConst=17)] public ushort[] R; public ushort a,b,c,d,e,f,g,h,i,j; } [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)] public static extern IntPtr CreateFile(string n, uint a, uint s, IntPtr sa, uint c, uint f, IntPtr t); [DllImport("kernel32.dll")] public static extern bool CloseHandle(IntPtr h); [DllImport("hid.dll")] public static extern bool HidD_GetPreparsedData(IntPtr h, out IntPtr p); [DllImport("hid.dll")] public static extern bool HidD_FreePreparsedData(IntPtr p); [DllImport("hid.dll")] public static extern int HidP_GetCaps(IntPtr p, out CAPS c); [DllImport("hid.dll", CharSet=CharSet.Unicode)] public static extern bool HidD_GetProductString(IntPtr h, StringBuilder b, int l); [DllImport("hid.dll", CharSet=CharSet.Unicode)] public static extern bool HidD_GetManufacturerString(IntPtr h, StringBuilder b, int l); } "@ $guid = '{4d1e55b2-f16f-11cf-88cb-001111000030}' Get-PnpDevice -PresentOnly -Class HIDClass,Keyboard | Where-Object { $_.InstanceId -match [regex]::Escape($Match) } | ForEach-Object { $path = '\\?\' + ($_.InstanceId -replace '\\','#') + '#' + $guid $h = [H]::CreateFile($path, 0, 3, [IntPtr]::Zero, 3, 0, [IntPtr]::Zero) if ($h -eq [IntPtr]-1) { "$($_.InstanceId): open failed"; return } $p = [IntPtr]::Zero; [void][H]::HidD_GetPreparsedData($h, [ref]$p) $c = New-Object H+CAPS; [void][H]::HidP_GetCaps($p, [ref]$c) $ps = New-Object Text.StringBuilder 256; [void][H]::HidD_GetProductString($h, $ps, 512) $ms = New-Object Text.StringBuilder 256; [void][H]::HidD_GetManufacturerString($h, $ms, 512) '{0,-50} page=0x{1:X4} usage=0x{2:X4} in={3} out={4} feat={5} prod="{6}" mfr="{7}"' -f $_.InstanceId.Split('\')[1], $c.UsagePage, $c.Usage, $c.InLen, $c.OutLen, $c.FeatLen, $ps, $ms [void][H]::HidD_FreePreparsedData($p); [void][H]::CloseHandle($h) }