How to clone VHD of Hyper V 2012 through Vbscript ?

239 views Asked by At

I am trying to clone a VHD file of Hyper V 2012 using wim image and diskpart commands. I am facing an issue in this as VHD of Hyper V 2012 contains 2 partitions. One for system reserved and second for data.I am creating wim image of data partition and deploys this image to new vhd file but when i try to up this new vhd bootmgr missing error occurs.How can i copy the system reserved partition in to the same new vhd and make it work ? or there is any other way to make this new VHD work.

1

There are 1 answers

1
Ansgar Wiechers On

Why would you want to fiddle around with WIM images and diskpart? Just copy the VHD(x) file and you're done.

Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile "C:\path\to\original.vhd", "C:\path\to\clone.vhd"

You need to make sure the VHD isn't mounted, though.

As a side note: you'd be far better off using PowerShell for dealing with Hyper-V, particularly in Server 2012. It has all the toys.