Convert VMWare [VHDX] To Hyper-V [VHD] In Powershell
I recently have received a virtual machine from a VMWare environment that I needed to get up an running in a Microsoft Hyper V. now not having access to the VM environment I needed to do this via PowerShell, normally a pretty simple task, however, I had to overcome the issue of a dodgy descriptor which was causing me errors. Thus steps below are as follows
-
- Download Microsoft Virtual Machine Converter 3.0 and install
- Open Powershell as an administrator and run the following command:
1 |
Import-Module 'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1' |
3. Now run the following command, replacing source and destination paths with that of your own
1 |
ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "E:\VMToConvert\VMDK\librenms_ubuntu_1604.vmdk" -DestinationLiteralPath “E:\VMToConvert\VHD\LIBRE.vhd” -VhdType FixedHardDisk -VhdFormat Vhd |
If you counter the following error:
ConvertTo-MvmcVirtualHardDisk : The entry 1 is not a supported disk database entry for the descriptor.
Follow these steps:
- download and extract dsfok tools
- use
dsfo.exe "E:\VMToConvert\VMDK\librenms_ubuntu_1604.vmdk" 512 1024 descriptor1.txt
to extract the descriptor - edit the descriptor file in Notepad++: comment the above-mentioned line , Delete NULL characters and other elements of the description as needed. Use
dsfi.exe"E:\VMToConvert\VMDK\librenms_ubuntu_1604.vmdk" 512 1024 descriptor1.txt
to inject the descriptor back into the VMDK - reissue the
ConvertTo-MvmcVirtualHardDisk
command