Q. How can I mount a Virtual Hard Disk (VHD) from Windows PowerShell?
John Savill
October 23, 2008
1 Min Read
A. It’s easier to use PowerShell to mount a VHD than to use the Windows Management Instrumentation (WMI) interface that I used in “Q. How can I mount a Virtual Hard Disk (VHD) in Hyper-V without additional programs?” Essentially, you create an object to link to the Msvm_ImageManagementService class, then mount the VHD via the object. The following command creates the object to point to the class.
$objVHDService = get-wmiobject -class "Msvm_ImageManagementService" -
namespace "rootvirtualization" -computername "."
You can then mount a VHD by using this command:
$objVHDService.Mount("d:virtualsdemo1demo1.vhd")
To unmount, you just use this command:
$objVHDService.Unmount("d:virtualsdemo1demo1.vhd")
The following screen shows the results of these commands:
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