Attach USB device to Hyper-V guest machine

Omid Shojaee 116 Reputation points
2022-01-24T12:21:15.937+00:00

Hello,

We have a software installed on one of our Hyper-V guest machines running Windows 2022 Datacenter edition. This software requires a hardware lock which is a USB device. The device is inserted into the USB port of the server, and the host machine sees it as an Input Device.

I need to somehow "attach" that USB device to the guest machine permanently and make it visible to the guest OS otherwise that software won't work. What is the solution?

The host machine is Windows 2022 Datacenter edition.

Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,531 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Nathan Freeman-Smith 66 Reputation points
    2023-01-23T10:58:02.3833333+00:00

    On host machine:

    1. Press Win+R type gpedit.msc and hit enter
    2. Go to Computer configuration > Administrative templates > Windows Components > Remote Desktop Services > Remote Desktop Connection Client > RemoteFX USB Device Redirection
    3. Select the only GPO there and Enable it and change the access rights to "Administrators and Users"

    On VM:

    1. Press Win+R type gpedit.msc and hit enter
    2. Go to Computer configuration > Administrative templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Device and Resource Redirection
    3. Select GPO "Do not allow supported Plug and Play device redirection" and disable it

    Reboot both machines and voila you can redirect anything to VM. When you connect via RDP a third icon next to Connection info icon will show up click on that and you can select anything local to be redirected to RDP.

    11 people found this answer helpful.

  2. Some One 36 Reputation points
    2022-08-28T02:16:05.917+00:00

    @Leon Laude , seems you are avoiding the real question...

    The answer is a big NO. Hyper-V CANNOT have pass-trough USB device other then storage. I.e. No ZigBee dongle, No Intel Neural Net USB dongles, no MFA/2FA dongles, not crypto tokens. I'm very surprised as VMWare ESXi had it up front in the beginning in early versions and it works great, and no "special disabling" of the device is required LOL.

    very disappointed in Microsoft yet again.

    7 people found this answer helpful.

  3. Tom-9560 10 Reputation points
    2023-06-21T08:44:15.5866667+00:00

    This is M$ Shame #56510

    While even open-source hypervisor supports real USB Passthrough,

    M$, after decades, is still limited to just attach USB Drives if they are willing follow a nightmare process with 20 steps.

    Isn't Microsoft even able to peek e.g. virtual box source code so get smart and understand how one could write SW to allow real USB Passthrough?

    2 people found this answer helpful.
    0 comments No comments

  4. Alex Calugarescu 5 Reputation points
    2024-01-05T07:53:40.0266667+00:00

    My setup is:

    Hyper V Server (i.e. the bare metal hypervisor only, but this guide should also work on Windows Servers)

    Ubuntu VM (named Leya) which runs on the HyperV Server with OpenHab and a ZWave USB dongle.

    1. Create the VmComport:
          Set-VMComPort -VMName 'Leya' -Number 1 -Path \\.\pipe\aeontech 
      
      Note: you can whatever name you want for your pipe.
    2. Install COMpipe
      1. Install Visual C++ Redistributable since Hyper V does not come with it preinstalled. You can download it from here: https://aka.ms/vs/17/release/vc_redist.x64.exe
      2. Download COMpipe from here: https://github.com/tdhoward/COMpipe/tree/master/x64/Release
      3. Find the USB COM port by running:
                                Get-PnpDevice -PresentOnly | Where-Object { $_.InstanceId -match '^USB' } | Select-Object Name,Description,InstanceId
        
        You should have a line like: USB Serial Device (COM3) USB Serial Device USB\VID_0658&PID_0200\5&1E7D8DB7&0&5
      4. Run COMpipe:
                .\COMpipe.exe -c \\.\COM3 -p \\.\pipe\aeontech
        
      5. On the VM, the COM port will be available as /dev/ttyS0
    3. As a final step, start COMpipe as a windows service. I used this service manager: https://nssm.cc/builds. The alternative is to start COMpipe manually but keep in mind this has to be done on every VM restart.
    1 person found this answer helpful.

  5. Leon Laude 85,651 Reputation points
    2022-01-24T12:33:51.57+00:00

    Hi @Omid Shojaee ,

    It's not as straight forward, but you could follow along the guide over here:
    https://adamtheautomator.com/hyper-v-usb-passthrough

    Edit: If you want to add USB devices, you'll likely need a third-party solution.

    ----------

    If the reply was helpful please don't forget to upvote and/or accept as answer, thank you!

    Best regards,
    Leon