How To Transfer Files Between VM and Host In Hyper-V

Windows 10 includes Hyper-V by default. You can enable it from “Turn Windows features on or off”. The latest version of Hyper-V does not allow transferring files between the host and the virtual machine directly. In this article, we discuss of ways to transfer files between the VM and the host easily.

There are three ways to copy or transfer files inside the VM from the host computer. One is to turn off the VM, mount the VHDX hard drive file in the host computer and copy the files to be transferred.

Second way is to create an ISO file and mount it inside the VM. Although it works if you have ISO creation software at your disposal, it requires extra effort. We are looking for a simple way to serve our purpose.

Third way is to join both, the host and the VM, to the same local area network. This can be quite easy if you are connected to a network. But if you are not connected to a network, it becomes increasingly difficult.

Creating a private network between host and guest VM

In this article, we will take the third approach but with a twist. We will create a private network between the host and VM and transfer files (or even share host drives with the VM). Just follow the steps below to make this happen:

  1. Open Hyper-V (Run –> virtmgmt.msc)
  2. From the right-hand menu, select Virtual Switch Manager.

    Hyper V Manager
    Hyper V Manager
  3. Select New Virtual network switch and select Internal as its type. Click on Create Virtual Switch button to create a new switch listing.

    New Virtual network switch
    New Virtual network switch
  4. Now open the VM settings. Under Network Adapter, select the name of the switch you just created.

    Select Network Adapter in Hyper V Settings
    Select Network Adapter in Hyper V Settings
  5. Next, we have to assign static IP addresses to the two network adapters. First go inside the VM and assign a static IP address to the network adapter.

    Assigning static IP address to the VM network controller
    Assigning static IP address to the VM network controller
  6. After this, we have to do the same for our host network adapter. Do not worry. These settings will not disturb your current network settings. If you go to Control Panel –> Network Connections, you will see a new network adapter by the name of the switch you created in step 3.

    Network Connections showing the new Virtual network switch from Hyper V
    Network Connections showing the new Virtual network switch from Hyper V
  7. Assign an IP to the network adapter.

After completing these steps, your host and guest Operating Systems will be connected to each other through a private network. You can use Remote Desktop (Run –> mstsc) to login to your VM and even change Remote Desktop Connection settings to show host drives inside the VM.

Remote Desktop Connection sharing host drives with VM
Remote Desktop Connection sharing host drives with VM

Hopefully this will resolve the problem of sharing files between the host and the guest machines permanently. There are other methods like enabling guest integration services and then transferring files through PowerShell command line but I don’t prefer those methods are they are harder to manage if we have large amounts of files to transfer. What methods do you use to transfer files between VMs and the host?

If you liked this post, Share it on:
Usman Khurshid is a seasoned IT Pro with over 15 years of experience in the IT industry. He has experience in everything from IT support, helpdesk, sysadmin, network admin, and cloud computing. He is also certified in Microsoft Technologies (MCTS and MCSA) and also Cisco Certified Professional in Routing and Switching.

15 comments

  • Usman Khurshid
    Anonymous

    How to copy from VM to host

  • Joe

    I found these instructions to have jumped too far ahead in the configuration of the virtual machine and was unable to follow them.

  • melissa
    melissa

    Does this method work if I have an ubuntu os for the VM? If so, what’s the command line to change the static IP in ubuntu?

  • bhavik

    what ip address i should set for communication in Vm and host adapter

    • Usman Khurshid
      A
      Usman Khurshid

      You can assign any IP address from Class A, B or C but I would recommend class C address. For example, you can use 192.168.150.x. Replace x with any digit between 1 and 254. Assign two different IP addresses of the same class to your host and the VM. For example, you can assign 192.168.150.150 to the host adapter and 192.168.150.151 to the VM adapter.

  • John

    Is there any reason you choose 192.168.13.12 for the gateway and DNS? Would think neither of those would need to be set.

    • Usman Khurshid
      A
      Usman Khurshid

      John this is only an example. I did it to test on my virtual machine. You can assign any IP addressing scheme of your choice.

  • Thomas Philipose
    Thomas Philipose

    Thanks for your notes. I could share files with the VM

  • John Clark
    John Clark

    I was able to copy a file to a VM by enabling the VM Guest services in Hyper-V Manager (version 10.0.16299.15), using the Copy-VMFile command in PowerShell as Administrator from the host (Windows 10 Pro v1709), and then disabling VM Guest services.

  • Zeiser

    Wouldn’t it be easier to just set up a shared folder on the VM at that last step? And then just connect to it from the file explorer of the host using ‘\\10.0.0.2’ in the address bar or whatever you set the VM ip to be.

    • Usman Khurshid
      A
      Usman Khurshid

      Yup that could be a great option too the I missed completely. Thanks for sharing the tip Zeiser.

  • Matt

    Not being able to copy files to and from the guest operating systems in Hyper-V is due to security reasons. You can see that guest integration services are disabled by default.

    If any virus attacks the VM, there is no way that it can propagate to the host Operating System making it safe. This is really useful on Hyper-V servers where the host server should never be touched and keeps on running 24/7.

  • Windows10Geek
    Windows10Geek

    What is the command line method of doing this?

    • Usman Khurshid
      A
      Usman Khurshid

      Good question!

      After enabling Guest Integration Services in VM settings, you can use the following PowerShell command to copy one file from host to guest:
      Copy-VMFile "WinVM" –SourcePath "C:\file.txt" –DestinationPath "C:\file.txt" –CreateFullPath –FileSourceHost

Leave your comment

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information