Convert VMware VMDK to Hyper-V VHDX

Convert VMware VMDK to Hyper-V VHDX

There are tools such as Solarwinds V2V that convert from one virtual disk format to another. However I wanted to see if it was possible to convert disk formats with PowerShell. You can do it. With Microsoft tools. But unfortunately not directly.

The Microsoft Virtual Machine Converter is Microsoft’s version of the VMware Virtual Machine Converter. However Microsoft’s tool will not allow you to convert VMware Workstation virtual machines directly and instead forces you to convert the hard disk in PowerShell and setup the new virtual machine in Hyper-V directly and attach the newly converted virtual hard disk.

A caveat before you start. If you have snapshots in your VMware virtual machine then converting using the steps below will only convert the first snapshot. So if you want to convert the current version of your snapshotted (is that even a word?!) VMware Workstation virtual machine, delete them all first.

First Download Microsoft Virtual Machine Converter (and the cmdlet reference) and open a new PowerShell Administrator session and import the module:

Import-Module MvmcCmdlet

If that doesn’t work as expected (as it didn’t when I tried it) then you will need to alter your PowerShell Modules path or import the module directly using:

    'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1'

Now that you have the module imported you can use the cmdlets to convert the VMware VMDK file to a VHDX using the command below. During conversion you will see the usual PowerShell progress bar. It can take some time (depending on how big the virtual hard disk is) so be patient.

ConvertTo-MvmcVirtualHardDisk `
    -SourceLiteralPath 'c:\path\to\my.vmdk' `
    -DestinationLiteralPath 'c:\path\to\new-vmdk\' `
    -VhdType DynamicHardDisk `
    -VhdFormat Vhdx

This creates a dynamic VHDX Hyper-V virtual hard disk. Refer to the cmdlets reference for other options.

Finally setup the new virtual machine in Hyper-V and attach the newly converted virtual hard disk to it:

New-VM `
    -Name 'New VM' `
    -Path 'c:\path\to\vm' `
    -VhdPath 'c:\path\to\new\created.vhdx'

All done!