Aug 14 2017

Print this Post

PowerShell Script: Convert-VMWareVM

In the past couple of days, I have been busy working on a new script to automate migration of VMs from VMWare to Hyper-V, or more precisely to System Center Virtual Machine Manager (VMM).

You may ask why on earth would I use a script to “automate” a function that already exists in VMM and there is the – now obsolete! – free Microsoft VM Converter (MVMC). Well, the script has some advantages over these options,

  • The script does not require Integrating vSphere with VMM.
  • The script offers more options than both VMM and MVMC can provide.

However, the script depends on binaries for MVMC to perform the VMDK to VHDX conversion, and since Microsoft decided to discontinue the tool and might soon remove it from their download website, I placed a copy of the required PowerShell module with the script. So you do not need to setup MVMC to use the script.

Also, I designed the script to run on the target Hyper-V host, that is of course also a VMM host. This is because the script will require lots of network traffic from VCenter and to the CSV or local storage of the Hyper-V host. Performing these from a remote workstation would waste a lot of time and may introduce errors.

So, on this target host, you will need to setup VMWare PowerCLI and VMM console.

The script is still a work in progress but is functional as is. In the future, I may make some changes and most probably add the ability to work without VMM, so stay tuned.

For now, the script performs the following actions,

  • [Optional] Uninstall VMWare Tools from a running VM. Then Shutdown the VM. This requires WinRM to be configured which is by default in Windows Server 2012 +
  • Confirm the following,
    • VM is Powered Off
    • Has no VMWare Tools installed [with option to skip this check – not recommended]
    • Has no snapshots.
    • Template used in VMM support BIOS or EFI as per the current configuration in VMWare.
  • Create a new VM in VMM as follows,
    • In a destination of your choice
    • Add vNICs if the machine has more than 1 vNIC. Not connected to any network.
    • [Optional] Copy CPU and Memory configuration from VMWare.
    • [Optional] Copy MAC addresses of vNICs.
  • Download, convert, and attach disks with the following options
    • Download to a separate staging folder.
    • [Optional] If the staging folder already contains a VMDK, download is skipped.
    • Fixed or Dynamic target VHDXs
    • [optional] Place additional disks in a different location than OS disk.
    • Mark the OS disk as “Contains the operating system for the virtual machine” in VMM.
    • Additional disks are attached to SCSI for Generation 1 and 2 VMs.
    • Delete the download VMDKs.
  • [optional] start the VM.


The script assumes the first disk in VMWare is the OS disk, and all others to be additional.

The script is available on GitHub here. Make sure you star the repository to receive updates as I enhance the script.


About the author

Walid AlMoselhy

Permanent link to this article: http://almoselhy.azurewebsites.net/2017/08/powershell-script-convert-vmwarevm/

Leave a Reply

Your email address will not be published. Required fields are marked *