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' } [void]$V2VConverterExe.ShowDialog() # 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" } [void]$VMDKFolderBrowser.ShowDialog() $VMDKs = ($VMDKFolderBrowser.SelectedPath | Get-ChildItem -Recurse -Filter *.vmdk).FullName if($VMDKs.Count -gt 0){ "Found {0} VMDK file(s)" -f $VMDKs.Count }else{ "No VMDK files found within {0}" -f $VMDKFolderBrowser.SelectedPath break } #Select the output folder $OutputFolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{ Description = "Select folder for converted VMs" } [void]$OutputFolderBrowser.ShowDialog() # 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 }