Skip navigation

Q. How can I mount a Virtual Hard Disk (VHD) file on my Hyper-V server from PowerShell?

A. Mounting a VHD with Windows 2008 R2 is easy using Disk Manager and the command line diskpart utility, but you can also use PowerShell with Msvm_ImageManagementService, as shown here.

 

$VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization" -computername "."
$VHDService.Mount("<path to vhd file>")

 

You can unmount using the $VHDService.Unmount command in place of $VHDService.Mount.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish