-3

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!

user212398
  • 51
  • 1
  • 5
  • 1
    We expect question askers to have done something to try to fix problems for themselves and explain what they've tried already - clearly you've done none, nor any training in vCenter either - how hard would it be to just read some basic stuff about it, vCenter can be dangerous in untrained hands. This site is for professionals, please try to put some effort in ok. – Chopper3 Jan 26 '22 at 13:19

1 Answers1

2

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.

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79