Hyper-v 3.0 PowerShell – Troubleshoot Import Incompatibilities | Quisitive
Hyper-v 3.0 PowerShell – Troubleshoot Import Incompatibilities
March 30, 2012
Matthew Dowst

In a previous post I covered importing a VM using PowerShell. In this post I am going to cover what to do if the import fails due to a compatibility issue.

In this example I am attempting to import a VM from the export ExportTest. To make things easier to read, I have set to the path the export XML file to the variable $Source.

PS C:>$Source = ‘E:ExportsExportTestVirtual Machines�FD602AC-2044-4A06-A0C3-019F70F21458.XML’

Next, I run the command to import the VM.

PS C:>Import-VM -Path $Source

The import fails with the message:

Import-VM : Unable to import virtual machine due to configuration errors. Please use Compare-VM to repair the virtual machine.
At line:1 char:1
+ Import-VM -Path $Source
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-VM], VirtualizationOperationFailedException
+ FullyQualifiedErrorId : Microsoft.HyperV.PowerShell.Commands.ImportVMCommand

As you can see from the error message above, the import failed due to a configuration error. We now need to determine the cause of the configuration error and resolve it. To do this we will use the Compare-VM Cmdlet.

Run the command below to generate a report that lists the VM’s incompatibilities with the host.

PS C:>$report = Compare-VM -Path $Source

Next, we need to display compatibility report.

PS C:>$report.Incompatibilities | Format-Table -AutoSize

Results:

Message
——-
Could not find Ethernet switch ‘TestSwitch’.
MessageId
——-
33012
Source
——-
Microsoft.HyperV.PowerShell.VMNetworkAdapter

This shows that the switch TestSwitch is assigned to the exported VM, but is not present on the host.

To resolve this we can disconnect the network adapter.

PS C:>$report.Incompatibilities[0].Source | Disconnect-VMNetworkAdapter

Next, we can regenerate the compatibility report to determine if there are any other issues.

PS C:>Compare-VM –CompatibilityReport $report

Results:

VM : Microsoft.HyperV.PowerShell.VirtualMachine
OperationType : ImportVirtualMachine
Destination : HOSTSERVER
Path : E:ExportsExportTestVirtual Machines�FD602AC-2044-4A06-A0C3-019F70F21458.XML
SnapshotPath : E:ExportsExportTestSnapshots
VhdDestinationPath :
VhdSourcePath :
Incompatibilities :

The results show that there are no incompatibilities, so we can now import the VM.

PS C:>import-vm -CompatibilityReport $report

One thing to make note of is, you cannot use the –Copy parameter with the –CompatibilityReport parameter. This means that when you use this method, the VM will be imported from the path listed in the report, and a new ID will not be generated. If you need to create additional VM’s from this template, you will need to export again from the VM it created.