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

John Savill

September 17, 2010

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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 "rootvirtualization" -computername "."
$VHDService.Mount("")

 

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

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like