More VM Tips: vhdk to vhdx

I had a previous post about Bitnami’s virtual machine offerings. What I failed to mention is that those  VM images are available in  VirtualBox or VMWare formats. I am partial to Hyper-V; so what’s an Mi4 developer on a Saturday night supposed to do?

Well after some searching a found a process using Powershell to convert VMWare hard drive images (vhdk files) to Hyper-v virtual hard disks (vhdx files).

Here is the tl;dr version.

  1. Install Microsoft Virtual Machine Converter
  2. Run Powershell-ISE  (not just regular powershell) as administrator
  3. Paste the following script in the white script area
     $modulearray = $env:PSModulePath.Split(";")
     foreach ($modulepath in $modulearray) {
     if ($modulepath -match "v1.0") {
     $moduledest = $modulepath+"\MvmcCmdlet"
     New-Item -Path $moduledest -ItemType directory
     Get-Childitem -Path "c:\Program Files\Microsoft Virtual Machine Converter" -filter *.dll -recurse | Copy-Item -destination $moduledest -Force
     Get-Childitem -Path "c:\Program Files\Microsoft Virtual Machine Converter" -filter *.psd1 -recurse | Copy-Item -destination $moduledest -Force

You only need to do the above steps once. You will need to follow the steps below everytime you convert a vm image

  1. Run Powershell as administrator (you can run Powershell-ISE if you want, but Powershell is just fine for this process)
  2. At the powershell prompt execute the following command
    ps>Import-Module mvmccmdlet
  3.  Execute the next command to take your source vhdk file to your destination vhdx file
     ps>ConvertTo-MvmcVhd -SourceLiteralPath c:\users\downloads\mybitnami.vmdk -DestinationLiteralPath c:\users\user\vms\mybitnami.vhdx -VhdType DynamicHardDisk -VhdFormat Vhdx

If you’re familiar with Hyper-V you should be able to take it from here. Create a new virtual machine and point the virtual hard drive to the vhdx file you created.

After that, go out and meet some friends or have fun with your family. That’s what people are supposed to do on a Saturday night.

Privacy Policy Made with in Texas.