How do I import a virtual machine into Hyper
Do you need to export Hyper-V VMs and transfer it from one host to another? How about export a VM from your development workstation to a Hyper-V host in production? If so, you’ve come to the right place! Show In this article, you will learn how to export and import a virtual machine using the Hyper-V Manager and PowerShell. Ready? Let’s GO!
PrerequisitesThis article will be a tutorial. If you plan on following along step-by-step, you will need the following:
Steps to Export Hyper-V VMsIf you’re not a fan of the command-line or you just have a single VM to save to disk, the Hyper-V manager is a solid choice. Assuming you’re on your Hyper-V host and you have a virtual machine running: 1. In your Windows search menu, type “hyper”. The Hyper-V Manager console should come up for you. If so, click on it to open. 2. Find the VM to export, right-click on it and click Export. Exporting VM using Hyper-V Manager The VM can be offline or running prior to exporting.3. Next, choose a folder to save the VM and configuration to and click on Export. Export Virtual Machine Dialog.
Once Hyper-V begins the export process, you will see the status of the export in the Hyper-V Manager window. Export Status in Hyper-V Manager4. Now, confirm all of the required files are present. You should see three sub-folders. These sub-folders contain all the files required for the exported VM to start; Snapshots, Virtual Hard disks, and Virtual Machines. Exported VM example
If your VM has more than one checkpoint, you will see multiple VMCX, VMRS and VMGS files for each checkpoint the VM has. Snapshots folder example
If all three folders are present and contain files, your export was successful. Using PowerShell to Export a VMIf you’re a fan of the command-line or have a lot of VMs to export, using PowerShell to export a VM is a great option also. To export a Hyper-V with PowerShell, use the Export-VM cmdlet. To do so, assuming you’re on your Hyper-V host and your VM is offline: 1. Open up a PowerShell console. 2. Query they Hyper-V host to get an inventory of your VMs and the name of the VM to export. This tutorial will export a VM called Alpine Linux 01. Virtual machine name to be used in Export-VM command3. Create a folder to export the VM to. This tutorial will export the VM to C:\Export_VM. New-Item -ItemType Directory -Name 'Exported_VM\' -Path 'C:\' 4. Now export the VM using the Export-VM cmdlet providing the name of the virtual machine for the Name parameter, the Path to the folder to save it to, and the PassThru parameter.
Export-VM -Name 'Alpine Linux 01' -Path 'C:\Exported_VM\' -Passthru Successful export of an offline virtual machine.
5. Now remove the VM from Hyper-V. Don’t worry! You have it saved! Remove-VM -Name 'Alpine Linux 01' Using Hyper-V Manager to Import a VMOnce you’ve exported the VM, disaster has struck and the VM is gone. No worries! You have already exported it to disk. Let’s get it back. To do so, assuming you’re on your Hyper-V host again: 1. Open Hyper-V Manager. 2. Click on the Import Virtual Machine menu item located on the right side of the Hyper-V Manager window. You are presented with the Import Virtual Machine wizard. Click Next. Import Virtual Machine Wizard3. Next, enter the path to the exported virtual machine you want to import and click Next. For this tutorial, the VM is saved to C:\Export_VM\Alpine Linux 01. Import Virtual Machine Wizard 4. Once Hyper-V discovers the VM configuration files inside of the folder (in this example, C:\Exported_VM\Alpine Linux 01\Virtual Machines\), Hyper-V will ask you to select a virtual machine to import. Choose the VM you want to import and click Next. 5. Next, choose the type of import you want to perform. First, let’s explore the options in more detail. When you choose the option ‘Register the virtual machine in-place (use existing unique ID)’, you are assuming the exported VM files are in their final location, meaning you are not moving the VM to a new folder. The exported VM files become the running state of the virtual machine. The UID does not change.
When you restore the virtual machine, you can choose a location or use the default Hyper-V location for the exported virtual machine files to be copied to. When you copy the virtual machine, it’s similar to restoring an exported VM, but with a new unique ID (UID). A new UID makes it possible to redeploy the same virtual machine multiple times to the same or different Hyper-V hosts. For the demonstration, let’s select the Import Type Copy the virtual machine. Copying the VM will generate a new unique ID (UID). Each Hyper-V VM is identified by a UID. This option is fine for now so click Next. Import Virtual Machine Wizard6. Since you chose the Copy option, you can change the location where the virtual machine files are stored. Click Next to accept defaults for this tutorial. Import Virtual Machine Wizard7. Finally, choose a location for the VM known as a Storage Folder. The Storage Folder is where the VHDX and AVHDX files will reside. For this tutorial, accept the default location and click Next. Import Virtual Machine Wizard8. Review the summary page and when you are ready, click Finish to begin the import. Completing Import Virtual Machine WizardWhen Hyper-V completes the import, it returns to the Hyper-V Manager window, and you will now see the imported VM, as shown below. Imported VMUsing PowerShell to Import a VMIf importing a VM via the Hyper-V Manager isn’t your thing, no problem. Use PowerShell! To import a VM with PowerShell, you’ll use the Import-VM cmdlet. Consider the following scenario: You’ve exported a VM, and it is sitting in C:\Exported_VM\, and let’s say that it is accidentally deleted, or maybe it is needed on a different Hyper-V host? Since it is already exported, it is essentially backed up and can easily be imported, therefore restoring the VM. If the Export-VM saves a VM to disk, the Import-VM cmdlet does the opposite; it reads a VM from disk and imports it into Hyper-V. 1. Assuming that you have already got a PowerShell console open and you are in the directory where you exported a VM (C:\Exported_VM). First, run the Get-ChildItem cmdlet with the Recurse switch to list out all of the files and make a note of the filename with the *.vmcx extension using the code below: Get-ChildItem -Recurse | Where-Object -Property Name -CLike *.vmcx
You may see output similar to the example below: Exported VM UID example – VM configuration file (vmcx)2. Next, use the Import-VM cmdlet with the Path parameter to specify the VMs configuration file (obtained in the previous step). Import-VM -Path '.\Alpine Linux 01\Virtual Machines\.vmcx' That’s it! You’ve registered the VM in place, using the same UID that the VM had when exported. Importing a VM in place3. Now verify the UID is the same as .vmcx file name when the VM was exported. You can use the code below to do just that by querying WMI: (Get-CimInstance -Namespace Root\Virtualization\V2 -ClassName Msvm_VirtualSystemSettingData -Filter "ElementName = 'Alpine Linux 01'").InstanceID You should see similar output as the example below: UID RetainedThe above example was a direct import from the VM configuration file, and the VM retained the original UID. In a production environment, you may want to generate a new UID to prevent an old VM being mistaken for a new VM. That’s where the Copy parameter comes in.
Import-VM -Path '.\Alpine Linux 01\Virtual Machines\.vmcx' -Copy -GenerateNewId This time, the imported VM does not contain the same UID as when exported. You see the old, and new UIDs in the screenshot below: Showing previous UID prior to import vs. new UID created with Copy and GenerateNewID parameters.Hyper-V now copies the VM to the default paths you saw earlier importing a VM using Hyper-V Manager but gives the VM a new UID. Next StepsIn this guide, you’ve learned how to export and import a Hyper-V VM using PowerShell and the built-in Hyper-V manager. Now that you know how to export and import Hyper-V virtual machines try setting up Automatic Virtual Machine Activation (AVMA) to activate Windows Server virtual machines hosted on Hyper-V. Can you convert a VMware to HyperYou can convert the VMs using the Convert Virtual Machine wizard. You can use this wizard from the VMM console. VMM 2019 UR3 supports conversion of VMware VMs to Hyper-V and Azure Stack HCI 20H2.
How do I import an ISO into HyperMicrosoft Hyper-V. Right-click the virtual machine and select Settings.. In the left pane, select the DVD drive.. In the Media pane, click Browse, and then select the ISO image.. Click Apply, and then OK.. How do I import an existing VMware virtual machine?Procedure. In the vSphere Client home page, navigate to Home > Hosts and Clusters.. From the inventory tree, right-click the host or cluster to which you want to import virtual machines.. Click Import VMs. ... . Select the source vCenter Server instance from which you want to import virtual machines.. Can you run a VirtualBox VM on HyperOracle VM VirtualBox can be used on a Windows host where Hyper-V is running. This is an experimental feature. No configuration is required. Oracle VM VirtualBox detects Hyper-V automatically and uses Hyper-V as the virtualization engine for the host system.
|