Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 34890

Quick and Easy VM Cloner

$
0
0

We had a situation in our lab where we had someone that wanted to do some load testing on a server by running 50 iterations of a Windows 7 OS that was preconfigured to boot up and launch some disk I/O heavy processes. I was contacted to come up with a quick and easy way to make 50 copies of this VM and mount them in Server 2012 Hyper-V so that our engineer wouldn't have to do it by hand. The following code it was I came up with to get this done. It is a PowerShell script designed to be run on the 2012 Hyper-V server itself that takes a few command line arguments:

VMCloner.ps1 <numberofVMs> <pathtosourceVHD> <destinationpath> <VMName>

So for example, I could make 50 copies of my source VM like this:

VMCloner.ps1 50 C:\source\Win7.vhd E:\VMs TestVM

This command would create 50 VMs in Hyper-V named TestVM1, TestVM2 etc. using my original located in C:\source and creates them all inside the E:\VMs directory.

The startup memory is set in code to 512MB of RAM, but you can easily change this or any other parameters as needed. Enjoy.


Viewing all articles
Browse latest Browse all 34890

Trending Articles