Using PowerShell to Convert a VHD to a VHDX

Using PowerShell to Convert a VHD to a VHDX

Rate This
  • Comments 7

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 1 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

  • The problem we are facing is that we convert a .VHD to .VHDX using powershell, the .VHDX file is unusable. If we convert the VHD to VHDX using the HyperV settings (GUI) the .VHDX does work. Is there any difference in the conversion process when using PowerShell and when using the GUI? Are there any parameters we forget to specify in PowerShell?

  • would it work for avhdx files as well?

    in fact, I want to know how would I convert a sequence of vhdx and avhdx files to vhd and avhd so that I keep that parent-child relationship between the converted files as well.

Page 1 of 1 (7 items)