What is Hyper-V Compare-VM and How to Use It | Quick Guide

If you receive the error “Import-VM: Unable to import virtual machine due to configuration errors. Please use Compare-VM to repair the virtual machine” when importing or migrating a Hyper-V VM to another host, you may need to compare VM incompatibilities before migration. This article will introduce you what is Hyper-V Compare-VM and how to use it.

Crystal

By Crystal / Updated on October 28, 2024

Share this: instagram reddit

Case: Please use Compare-VM to repair the virtual machine

 

Hi, When I use command ‘import-vm’ to import VM, I got the error “import-vm: Unable to import virtual machine due to configuration errors. Please use Compare-VM to repair the virtual machine.” It seems to imply that there is an incompatibility issue. Is there any way to resolve it and make sure that the vm can be imported successfully?

- Question from social.technet.microsoft.com

Microsoft Hyper-V allows you to migrate virtual machines from one host to another host. You can achieve this by exporting and importing virtual machines or performing Hyper-V Live Migrations between 2 different Hyper-V hosts.

However, importing VMs from one host to another can run into issues due to the differences in configuration of the hosts. A common issue is that a virtual switch does not exist on the new Hyper-V host. And you may be presented with an error “Import-VM: Unable to import virtual machine due to configuration errors. Please use Compare-VM to repair the virtual machine.”

Please use Compare-VM to repair the virtual machine

So, what is Hyper-V Compare-VM, and how to use it? This article will answer it for you.

What is Hyper-V Compare-VM

Microsoft provides the PowerShell program to perform task automation and configuration managements tasks. Administrative tasks are generally performed via cmdlets, and Compare-VM is one of the cmdlets.

Windows PowerShell

The Compare-VM cmdlet compares a virtual machine and a virtual machine host for compatibility, returning a compatibility report. When you are trying to import or migrate a virtual machine whose configuration is not compatible with the target server that running Hyper-V, it is useful to use Compare-VM to troubleshoot the import failure in the first step.

Using the Hyper-V Compare-VM cmdlet for basic virtual machine and host evaluation purposes is a simple process. Next, I will show you how to do this.

How to compare a VM with another Hyper-V host

To import or migrate a virtual machine to another Hyper-V host, if they are incompatible, for example, you didn’t assign the required Virtual Switch to the target host, then you may receive the error “Import-VM: Unable to import virtual machine due to configuration errors. Please use Compare-VM to repair the virtual machine”.

To troubleshoot, you can use Hyper-V Compare-VM to compare the VM and the Hyper-V host and create a compatibility report to verify that the VM is compatible to run on the destination host or not.

You just need to specify the name of the VM using the –Name parameter and the host that we are planning to migrate to using the –DestinationHost parameter. Launch Windows PowerShell and run the command:

Compare-VM -Name -DestinationHost

For example, compares virtual machine TestVM and Hyper-V host TestDestinationHost for compatibility. It command will be like:

PS C:\> Compare-VM -Name TestVM -DestinationHost TestDestinationHost

Hyper-V Compare-VM

✍Note: If you receive error “Compare-VM: Live migrations of virtual machines cannot be sent to the destination host because no migration networks are specified for incoming live migrations”, try add the IP Addresses of your Hyper-V host by clicking Hyper-V Settings > Live Migrations > use these IP Addresses for Live Migrations > Add on Hyper-V Manager.

Enable Hyper-V live migrations

Backup VMs before migration to protect your data from loss

Backup is always the necessary measure to protect data from accident disasters, especially for data centers. You could lose important business data if there’s any corruption during your VM importing or migration. Therefore, backup Hyper-V VMs regularly and before risky operations is necessary for protecting your Hyper-V VM data from such accidental loss.

Here I introduce you to a free Hyper-V backup software -- AOMEI Cyber Backup. It automates the backup process of multiple VMs, and sends email notifications if there's an error.

💡Agentless Backup:

Creating complete and independent image-level backup for VMware ESXi and Hyper-V VMs.

🎁Multiple Storage Destinations:

Backing up data to local, network share or cloud destinations.

🐱‍💻Centralized Management:

Using a centralized web console to manage your VMware virtual machines regardless of sockets and hosts.

✨Fast Disaster Recovery:

Restoring the entire VMware VM to a usable state quickly without re-creating and configuring a new VM.

Next, I will show you how to backup Hyper-V VMs FREE in simple steps. You can click the following button to download and use the AOMEI Cyber Backup Free Edition with no time limit.

Download FreewareVMware ESXi & Hyper-V
Secure Download

*You can choose to install this VM backup software on either Windows or Linux system.

How to backup and restore Hyper-V VMs [free but powerful solution]

1. Bind Devices: access to AOMEI Cyber Backup web client, navigate to Source Device > Hyper-V > + Add Hyper-V to add a Hyper-V host. And then click > Bind Device.

Add Hyper-V Host

2. Create Backup Task: navigate to Backup Task > + Create New Task, and then set Task Name, Backup Type, Device, Target, Archive and Schedule.

  • Device: cover multiple VMs on the host in one backup task.
  • Target: select to back up to a local path, or to a network path.
  • Archive (Optional): store backups to AWS by selecting the added S3 bucket.
  • Schedule (Optional): choose to perform full or incremental backup, and automate execution according to the frequency you specified.

Schedule Hyper-V VM Backup

3. Run Backup: click Start Backup and select Add the schedule and start backup now, or Add the schedule only.

Start Backup

4. Restore VM: Click > Restore on the backup task to open a wizard, and click Select Content to specify a restore point. Select to Restore to original location, and click Start Restore.

Restore Hyper-V VM

Created backup tasks will be listed and monitored separately for progress checking and schedule changing.

Summary

When importing or migrating a Hyper-V VM to another host, you may receive the error: “Import-VM: Unable to import virtual machine due to configuration errors. Please use Compare-VM to repair the virtual machine.” It implies that there may be incompatibilities between the VM and the target host, for example, the Hyper-V Virtual Switch not working or haven’t assigned. To resolve this issue, you just need to troubleshoot using Hyper-V Compare-VM as it says.

In this article, I briefly introduced what is the Hyper-V Compare-VM cmdlet and showed how to use it to compare VM incompatibilities with a Hyper-V host before migration.

Crystal
Crystal · Editor
Crystal is an editor from AOMEI Technology. She mainly writes articles about virtual machine. She is a positive young lady likes to share articles with peolpe. Off work she loves travelling and cooking which is wonderful for life.