Convert a VMDK (VMWare) file to VHDX (Hyper-V)

Microsoft provides a free tool to convert an existing virtual machine to a Hyper-V virtual machine: Microsoft Virtual Machine Converter.

This tool has a graphical interface allowing to carry out the most common operations. However, in some cases (often non-enterprise), you must use the supplied PowerShell cmdlet.

For example, the following script converts a virtual hard disk of type VMDK (VMWare) to a virtual disk in VHDX (Hyper-V) format :

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

$vmdk="sample.vmdk"
$vhdx="sample.vhdx"

ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath $vmdk -DestinationLiteralPath $vhdx