How to Move a Hyper-V Virtual Machine to another Host?
When working with Hyper-V, you may need to move a virtual machine from one computer to another, or to restore the virtual machines after reinstalling Windows on the Hyper-V host computer.
Migrating a Hyper-V VM to a different computer can be done in three (3) ways, and in this tutorial we will present with detailed instructions the steps to perform this task.
How to Transfer Hyper-V VM's to a Different Computer or How to Backup & Restore Virtual Machines on Windows 10/11.
To backup and restore Hyper-V virtual machines on the same or another computer, you can use either the "Import/Export" feature in Hyper-V Manager, or the "Import-VM" & "Export-VM" commands in PowerShell, or copy and move the Virtual Machine files manually. (Of the (3) ways, the easiest is to export and import each virtual machine using the Hyper-V Manager export/import feature).
Important Note: Before you continue moving a Hyper-V virtual machine to another computer, note that you can import a virtual machine to a Hyper-V host running a newer version of Hyper-V, but you cannot import a virtual machine that was created in a newer version of Hyper-V in an older version of Hyper-V. This practically means that you can move a virtual machine from a Windows 10 PC to a Windows 11 PC, but you cannot move a virtual machine from a Windows 11 PC to a Windows 10 PC.
- Import-Export VM using Hyper-V Manager.
- Import-Export VM using PowerShell.
- Transfer Hyper-V Virtual Machine files manually.
Method 1. Transfer a Virtual Machine to another Host using Export & Import commands in Hyper-V Manager.
As mentioned above, the easiest method to backup & restore virtual machines in Hyper-V, is by using the Export/Import feature in Hyper-V Manager.
Step 1. Export a Virtual Machine from Hyper V Manager.
1. Right-click on the Virtual Machine you want to backup or to transfer to another host and choose Export.
2. In 'Export Virtual Machine' window, click Browse and select a folder to save the machine's files.
3. Click the Export button.
4. After exporting the virtual machine, you should have the following three (3) folders in the "Export" location:
-
Virtual Hard Disks
-
Virtual Machines
-
Snapshots
5. Copy these folders to a USB drive and continue to the next step when you are ready to migrate/restore the virtual machine.
Step 2. Import a Virtual Machine from Hyper V Manager.
To import the Hyper-V VM on the same or another host computer:
1. Open Hyper-V manager and click Import Virtual Machine.
2. Click Next on the first screen and then click Browse.
3a. Then, from the location where you saved the extracted virtual machine files, select the "Virtual Machines" folder and click Select Folder.
3b. When done, click Next.
4. Verify that you have select the correct VM machine to import and click Next.
6. Now select the 'Import' Type and then click Next on the following screens to complete the import.*
- Register the virtual machine in place (use the existing ID): Imports the virtual machine from its configuration file and retains the virtual machine's ID. The virtual machine is registered in-place, so its files are not copied to another location.
- Restore the virtual machine (use the existing ID): To import the virtual machine specifying your own path for the virtual machine files.
- Copy the virtual machine (create a new unique ID): To create a new ID for the VM machine and to import and move the virtual machine files to the default Hyper-V location.
* Note: In this example we chose the "Restore" import type, in order to keep the same machine's ID and to specify where to import and copy the virtual machine's files.
7. On the next screen and if you want to change the storage location of the virtual machine files, select Save the virtual machine in a different location and below specify where you want to save the virtual machine files. When done, click Next.*
* Note: In this example we chose to store the VM files in the default Hyper-V location: "C:\ProgramData\Microsoft\Windows\Hyper-V\"
8. On the next screen, specify where you want to store the imported virtual disk and then click Next.*
* Note: In this example we chose to store the virtual disk in he default Hyper-V location: "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\"
9. On the 'Connect Network' screen choose Default Switch and click Next.
10. In the 'Summary' screen, review your settings and click Finish to import the virtual machine.
Method 2. Move a Hyper-V Virtual Machine to another Host using PowerShell.
The next method to transfer Hyper-V VMs, is by using the Export-VM & Import-VM commands in PowerShell.
Step 1. Export Virtual Machine from PowerShell.*
1. Shutdown the Virtual Machine.
2. Then, open PowerShell as Administrator and issue the following command to export the VM to a new folder:*
-
Export-VM -Name VMName -Path VMExportPath
* Note: Where "VMName" is the name of the virtual machine you want to export its files (e.g. "Windows11_PRO" in this example), and "VMExportPath" is the path/location to save the virtual machine's files (e.g. on folder "D:\Hyper-V_Export" in this example).
-
Export-VM -Name Windows11_PRO -Path D:\Hyper-V_Export
3. When the exporting process is completed, you should have the following three (3) folders in the "Export" location:
-
Virtual Hard Disks
-
Virtual Machines
-
Snapshots
5. Copy these folders to a USB drive and continue to import the VM on the new computer, either by using the instructions on Step-2 below, or by using the instructions on Step-2 of Method-1 above.
Step 2. Import Virtual Machine from PowerShell.
On the host where you want to import the Virtual Machine you exported in previous step, do the following:
1. Plug the USB disk with the exported folders from the previous step on the PC.
2. Optionally: Transfer or copy the three (3) exported folders from the previous step on the new host, in the following location(s):*
- The Virtual Hard Disks folder in:
C:\ProgramData\Microsoft\Windows\ - The Virtual Machines folder in:
C:\ProgramData\Microsoft\Windows\Hyper-V\ - The Snapshots folder in:
C:\ProgramData\Microsoft\Windows\Hyper-V\
* Notes:
1. This step is optional, depending on the type of import you want to perform (see below).
2. These are the default Hyper-V store locations. If you want, to use a different location to store the virtual machine files, then transfer these folders to your custom location, or see below).
4. Then open the "Virtual Machines" folder and copy on the notepad the name of the VMCX file (e.g. "35481D49-3E07-4B44-8C15-E725F671BB72.vmcx" in this example).
5. Now, open PowerShell as Administrator and issue one of the following commands according the type of the import you want to perform: Register, Restore or Copy.
A. Register: To keep the virtual machine files in place (files not moved) and use the existing ID:*
- Import-VM -Path 'VMExportPath\NAME.vmcx'
* Where: "VMExportPath" is the full path of the VMCX file.
For example: To import the virtual machine and keeping the virtual machine files in the location from which you import them (e.g. in "C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\" folder in this example), give this command:
- Import-VM -Path 'C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\35481D49-3E07-4B44-8C15-E725F671BB72.vmcx'
B. Restore: To copy the virtual machine files in a different location from the default, and keep the same VM's ID:
Import-VM -Path 'VMExportPath\NAME.vmcx' -Copy -VhdDestinationPath 'VHDPath' -VirtualMachinePath 'VMPath'
* Where: "VMExportPath" is the full path of the VMCX file, "VHDPath" is the new location to store the Virtual Hard disk files and "VMPath" is the location to store the Virtual Machine's configuration files.
For example: To import the virtual machine from the location where you saved the exported VM files in step-1 above (e.g. from "D:\Hyper-V_Export\Windows11_PRO\" in this example), to "C:\HyperV\WIN11_PRO" folder, give this command)
- Import-VM -Path 'D:\Hyper-V_Export\Windows11_PRO\Virtual Machines\35481D49-3E07-4B44-8C15-E725F671BB72.vmcx' -Copy -VhdDestinationPath 'C:\HyperV\WIN11_PRO' -VirtualMachinePath 'C:\HyperV\WIN11_PRO'
C. Copy: To copy the virtual machine files from another location to the default Hyper-V store location and create a new unique ID:
- Import-VM -Path 'VMExportPath\NAME.vmcx' -Copy -GenerateNewId
For example: To import the virtual machine from the location where you saved the exported VM files in step-1 above (e.g. from "D:\Hyper-V_Export\Windows11_PRO\") in this example) to the default Hyper-V location and create a new ID for the VM, give this command:
- Import-VM -Path 'D:\Hyper-V_Export\Windows11_PRO\Virtual Machines\35481D49-3E07-4B44-8C15-E725F671BB72.vmcx' -Copy -GenerateNewId
Method 3. Migrate Hyper-V Virtual Machine to a Different Computer Manually.
Manually moving a Hyper-V machine to a different host is not recommended because it is a more time-consuming process than the previous methods explained above. However this method is useful in case any of the above methods don't work properly or you can't boot into Windows on the host machine.
Step 1. Find out the location of the Virtual Machine's files.
To move manually a Hyper-V virtual machine to another host, you have to transfer the following virtual machine's files to the new host and then to import the VM from these files:
-
- Virtual Hard Disk
- Configuration files
- Checkpoints (Snapshots)
By default Hyper-V stores these files for each virtual machine in the following locations & folders (in bold letters) on the disk:
- Virtual Hard Disk: C:\ProgramData\Microsoft\Windows\Virtual Hard Disks
- Configuration files: C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines
- Checkpoints: C:\ProgramData\Microsoft\Windows\Hyper-V\Snapshots
Therefore, if you cannot boot into Windows on the host computer, you need to connect its hard drive to another computer and copy the mentioned folders to a USB disk and then transfer them to the new host computer.
However, If you can boot to Windows its advised to verify the location of the VM files by following the instructions below:
A. Virtual Hard Disk: To find out where the Virtual Disk of the virtual machine you want to move/copy to another host is stored:
1. Right-click on the Virtual Machine that you want to move and select Settings.
2. Go to SCSI Controller > Hard Drive to see the path of the "Virtual Hard Disks" folder.
B. Snapshots: To find out where the Snapshots (Checkpoints) of the virtual machine you want to move/copy to another host are stored:
1. Right-click on the Virtual Machine that you want to move and select Settings.
2. Go to Checkoints tab to see the path of the "Snapshots" folder.
C. Configuration files: To find out where the configuration files of the virtual machine you want to move/copy to another host are stored:
1. In Hyper-V Manager, click Hyper-V Settings.
2. Go to Virtual Machines tab to see the path of the "Virtual Machines" folder.
Step 2. Copy the VM's Virtual Hard Disk files to USB.
* Note: In this example we show how to transfer a virtual machine's files to another host using an external USB drive.
1. Right-click on the virtual machine that you want to copy/move to another host and select Settings.
2. Select SCSI Controller > Hard Drive from the left.
3. Then on the right, look under Virtual hard disk and note where the virtual disk file is stored on the disk.
4. Now, navigate to the location you noticed, and copy to a USB drive all the files started with the name of the virtual machine. (e.g. "Windows11_PRO" in this example), under a folder named "Virtual Hard Disks".
Step 3. Copy the VM's Configuration Files to USB.
1. Open PowerShell as Administrator and issue the following command, to find out the configuration files of the virtual machine and the location of the "Virtual Machines" folder on the disk (where the configuration files are stored):*
-
Get-VM | Select VMName, VMID, ConfigurationLocation
* Note: Where "VMName" is the name of the virtual machine you want to move to another host. (e.g. "Windows11_PRO" in this example)
-
Get-VM | Select Windows11_PRO, VMID, ConfigurationLocation
2. After issuing the above command, note the filename of the configuration files (VMId) and their location on the disk (ConfigurationLocation).
3. Now open Explorer, navigate to the Configuration Location (e.g. "C:\ProgramData\Microsoft\Windows\Hyper-V" in this example), open the "Virtual Machines" folder and copy to a USB disk all the files that has the same name as the machine's VMId (e.g. " 35481d49-3e07-4b44-8c15-e725f671bb72" in this example), to a new folder named "Virtual Machines".
Step 4. Copy the VM's Snapshots (Checkpoints) to USB.
1. Open PowerShell as Administrator and issue the following command, to find out the number of snapshots of the virtual machine:
-
Get-VMCheckpoint VMName
* Note: Where "VMName" is the name of the virtual machine you want to move to another host. (e.g. "Windows11_PRO" in this example)
-
Get-VMCheckpoint Windows11_PRO
2. After issuing the above command, note the snapshot names and the date and time they were created.
3. Then issue the following command to find out the filename(s) of the snapshot file(s).
-
Get-VMCheckpoint VMName| Format-List
* Note: Where "VMName" is the name of the virtual machine you want to move to another host. (e.g. "Windows11_PRO" in this example)
-
Get-VMCheckpoint Windows11_PRO| Format-List
4. Now scroll down and note the filenames (Id) of the snapshot files. (e.g. "43e2d842-f59f-446b-84b5-1c4edf9f0d04" & "909facae-c076-4dff-9bfb-9214e0063daa" in this example)
5. Finally, navigate to the "Snapshots" folder on the disk and copy to USB all the files that has the same name with the ones you noted above, to a new folder named "Snapshots".
6. After performing the above steps, you should have the following three (3) folders with the corresponding files you transferred in the steps above on your external USB drive:
-
Virtual Hard Disks
-
Virtual Machines
-
Snapshots
7. Follow the instructions on Step-2 of the Method-1 or Method-2 above to import the files of the VM on the new host.
That's it! Which method worked for you?
Let me know if this guide has helped you by leaving your comment about your experience. Please like and share this guide to help others.
We're hiring
We're looking for part-time or full-time technical writers to join our team! It's about a remote position that qualified tech writers from anywhere in the world can apply. Click here for more details.
- FIX: Outlook or Word closes or crashes when typing. (Solved) - September 9, 2024
- FIX: Hyper-V did not find Virtual Machines to import from location. - September 3, 2024
- How to Move a Hyper-V Virtual Machine to another Host? - August 28, 2024