Batch Convert VMware VMDK to Hyper-V

I’m doing some conversion of legacy VMs and have been using the StarWind Converter to convert the disks. This utility has been around for years and I’ve used it on and off for a long time whenever converting VMs from VMware to Hyper-V.

It has a GUI but that’s not practical for converting many VMs – the disk conversion process take a long time so I want to just be able to point something at a folder and let it chug along converting anything it finds.

StarWind Converter comes with a command line utility V2V_ConverterConsole.exe and so I wrote a PowerShell script to call this. You may wish to read the documentation for the command line utility.

Export all the VMs to OVF, this will give you a folder per VM containing an .ovf file, a .vmdk file and a .mf file. Make sure all these folders are in the same place, the script will ask you for this folder folder of folders containing the exported VMs.

Install StarWind Converter. The script will ask you to select the location of the V2V_ConverterConsole executable.

Finally it’ll ask you for a folder to put the converted virtual disks into.

Add-Type -AssemblyName System.Windows.Forms

# Select the V2V converter console exe
$V2VConverterExe = New-Object System.Windows.Forms.OpenFileDialog -Property @{ 
    InitialDirectory = "C:\Program Files\StarWind Software\StarWind V2V Image Converter"
    Title = "Select the StarWind V2V Converter Console executable"
    Filter = 'V2V_ConverterConsole.exe|V2V_ConverterConsole.exe'

# Select the input folder - should contain subfolders for the exported VMware VMs
$VMDKFolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
    ShowNewFolderButton = $false
    Description = "Select Exported VMs folder"
$VMDKs = ($VMDKFolderBrowser.SelectedPath | Get-ChildItem -Recurse -Filter *.vmdk).FullName
if($VMDKs.Count -gt 0){
    "Found {0} VMDK file(s)" -f $VMDKs.Count
    "No VMDK files found within {0}" -f $VMDKFolderBrowser.SelectedPath

#Select the output folder
$OutputFolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
    Description = "Select folder for converted VMs"

# Convert each VMware VM to Hyper-V
foreach($VMDK in $VMDKs){
    $VMDKFolder = $VMDK | Split-Path -Parent
    $OVF = (Get-ChildItem -Path $VMDKFolder -Filter *.ovf).FullName
    [XML]$OVFXML = Get-Content -Path $OVF

    $VHDFolder = Join-Path -Path $OutputFolderBrowser.SelectedPath -ChildPath (Split-Path $VMDKFolder -Leaf)
    $VHD = Join-Path -Path $VHDFolder -ChildPath (($VMDK | Split-Path -Leaf) -replace ".vmdk",".vhd")
    if(!(Test-Path $VHDFolder)){
        New-Item -Path $VHDFolder -ItemType Directory
    "Converting {0}" -f $VMDK
    & $V2VConverterExe.FileName convert in_file_name="$VMDK" out_file_name="$VHD" out_file_type=ft_vhd_thin

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.