Clone VMWare VM to multiple VMs

I use vCenter cluster of several ESXi servers, with VSAN storage.
I need to setup multiple VMs from a single vm.
Is there a way to clone one VM to multiple VMs via vCenter? is there a feature for that?
If not – I would like to use a script, that will run the cloning according to parameters:
source VM to clone, new vm name, destination folder, IP, and hostname.
I saw some examples of scripts, but couldn’t understand where to run it…
I logged in to vCenter using SSH, but none of the commands worked.
Eventually, I’d be happy to have a step by step guide for this process.

Thanks all!

Answer

You need to create a customization specification for the VMs. These are defined in vCenter and allow you to predetermine some settings that are then used when cloning the VM.

Afterwards you can easily use the specification in scripts, for example with PowerCLI:

$sourceVM = get-vm oldvm
$specs = Get-OSCustomizationSpec -name "MyCustomization"
$vmhost = Get-VMHost esx.example.com
"clone1","clone2" |% { 
    new-vm -vm $sourceVM -Name $_ -OSCustomizationSpec $specs -VMHost $vmhost -Location $sourceVM.Folder
}

This would create two clones from the vm oldvm. The specification can be configured to change the hostname of the clone to the name of the VM, network settings can be set to be determined by DHCP or to be specified during cloning.

Attribution
Source : Link , Question Author : user212398 , Answer Author : Gerald Schneider

Leave a Comment