I’ve built this VMware PowerCLI (formerly VI Toolkit) script for a customer that required multiple simultaneous clonings that he could easily configure to back up his production VMs. I’ve included a mechanism to limit the maximum number of concurrent clonings to maximise performance, so when using this script it will take some experimentation to find the ‘magic number’ to minimise the time used to do a full clone run.
The attached ZIP file includes three files:
- ScriptClone.cfg – The config file, one VM per line, will be run in order from top to bottom
- ScriptClone.ps1 – The actual script, includes three extra settings for you to configure
- ScriptClone.bat – A batch file to run the script, change the paths to suit your system
The script will power down the target VM if it already exists, then delete it from disk and then clone the source to the target. The power down steps are included three timeswith a 20 second gap because experience has shown that powerdowns don’t always go smoothly. Also after the deletion of the ‘old’ target VM there is a wait of 2 minutes to give vCenter a chance to clean it all up and update the inventory.
As with all programming this code is based on larger of smaller elements of the work of many others before me, too many to mention all here, but I am of course grateful for everyone’s hard work.
Download the ZIP file here.
