Attach/Detach a VHD using Powershell


hello,

is there anyway attach or detach vhd file using powershell v2? can diskpart command placing in batch file i'm looking way poershell.

thanks in advance.


milad

sure, gwmi method you'll in powershell 2.0, sourced tech recipes. 

$objvhdservice = get-wmiobject -class "msvm_imagemanagementservice" -namespace "root\virtualization" -computername "." #to mount vhd file: $objvhdservice.mount("e:\virtual\test\test.vhd")

#to unmount vhd file:

$objvhdservice.unmount("e:\virtual\test\test.vhd")

http://www.tech-recipes.com/rx/3704/powershell-how-to-mount-a-virtual-hard-disk-vhd/

in windows 8, powershell 3.0 have built in diskpart cmdlets.

http://www.thomasmaurer.ch/2012/04/replace-diskpart-with-windows-powershell-basic-storage-cmdlets/


don't forget mark posts answered drop off unanswered post filter.





Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Indexing Server

Schannel Issue

oclist /xml or /?