"Microsoft - Virtual Hard Disk attach/detach using powershell"

Published: Fri 21 July 2017

In content.

You can create Virtual Hard Disk by accessing diskmgmt.msc and attach as if it is actual hard disk drive. Only difference is it is virtual. It should be easy to move those files around, from one computer to another.

Note: Be sure to try this with appropriate user permissions

To create new virtual hard disk:

  • you need to open up ```diskmgmt.msc```
  • click on ```Create```. You will see two options, ```Create VHD``` and ```Attach VHD```
  • Create new virtual hard disk. You can choose standard ```VHD``` or ```VHDX```.
  • Set the size and allocation options. Here you can set it to expand dynamically or fixed size.
  • Once you are done with vhd creation, you need to initialize it according to your hard disk partition type.
  • Now you can attach the vhd file you have created earlier

To attach/detach vhd, I will be using powershell with administrative rights. Make sure you have absolute path of the vhd file.


Mount VHD

Mount-VHD -path ""

Unmount VHD

Dismount-VHD -path "vhd_absolute_path"

where absolute path:


Absolute path describes actual path to a file in a file system.


https://technet.microsoft.com/en-us/bb738381.aspx https://www.top-password.com/blog/mount-and-unmount-vhd-vhdx-from-command-line/ http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/