Private/Get-RedirectedUsbDevice.ps1
function Get-RedirectedUsbDevice { [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateSet('PnP', 'USB')] [System.String]$DeviceType ) try { Add-Type -TypeDefinition $RedirectedUsbDeviceCSCode -Language CSharp $getRedirectedUSBDeviceCommandObj = New-Object -TypeName GetRedirectedUSBDeviceCommand $outputObj = $getRedirectedUSBDeviceCommandObj.Invoke() | Where-Object {$_.DeviceType -eq $DeviceType} if ($outputObj.Count -lt 1) {Write-Output $null} else {Write-Output $outputObj} } catch { # This will only be used for tab/menu completion for Edit-VMConnectConfig's -RedirectedPnpDevices and -RedirectedUsbDevices parameters # so if there's an error/exception, just do "return". return } } #function Get-RedirectedUsbDevice |