With the Hyper-V GUI manager, its just too headache to copy a freshly installed OS to multiple new VM,
especially while testing clustering software like DRBD or Ceph.
Here’s a quick powershell script to copy a Centos7 source VM into 5 new VM:
[shell]ForEach ($number in 1..5){
#Path to our source VHD
$srcVHDPath = “D:\Hyper-V\Centos7-Ori.vhdx”
#Path to create new VHDs
$newVHDPath = “D:\Hyper-V\Centos7-$number.vhdx”
copy $srcVHDPath $newVHDPath
New-vm -Name “Centos7-0$number” -MemoryStartupBytes 2048MB -VHDPath $newVHDPath
}
[/shell]