Using PowerShell to Convert a VHD to a VHDX

Using PowerShell to Convert a VHD to a VHDX

Rate This
  • Comments 5

Yesterday I showed you how to convert a VHD file to a VHDX using the Hyper-V Manager user interface. Today I want to show you that it is even easier to do using PowerShell:

image

All you need to do is run the following command:

Convert-VHD .\test.vhd .\test.vhdx

We will figure out whether you want the new file to be a VHD or VHDX depending on the file extension that you provide.  You can also specify whether you want a dynamic or fixed disk – but that is optional.

Cheers,
Ben

Leave a Comment
  • Please add 5 and 7 and type the answer here:
  • Post
  • Excellent , just like VHDtool.exe but running from powershell.

  • Hi ben, is the 'FileSize' before & after conversion correct?

  • Ha

    Funny thing is I did this just yesterday on converting some large fixed disk .vhd to .vhdx  A significant benefit is you can open up additional powershell instances and convert more than one .vhd at a time.  Worth pointing out as well that the new file will take on the characteristics of the old (as far as I understand) that is to say the target .vhdx will be a dynamic .vhd if the source was dynamic, and likewise for a fixed disk .vhd being converted.  Otherwise as you point out you can override the default behaviour.

    As an aside, I'd love a way of being able to easily convert a .vhd or .vhdx file to a wim.  Either by a one line tool or by a script.  

    Cheers

    Janson

  • Mario -

    Yes, VHDX files tend to be a bit larger than VHD files - as we preallocate a buffer for performance reasons.

    Cheers,

    Ben

  • Hi Ben, what is the use of -passthru option in the convert-vhd command

Page 1 of 1 (5 items)