Clone-List Function

Clone-List Function

If you've been managing a virtual environment for any period of time you've probably received an email requesting that you clone a long list of VMs prior to an upgrade.  I have received this request a variety of times and decided this needed to be automated.


The function performs the following tasks:

  • Clones each VM with suffix "clone-"
  • Places the cloned VM in the same folder as the original to maintain permissions for application owners.
  • Assigns clone to random host within the cluster. This was done in case the clones needed to be started up on a cluster where DRS is not enabled or available.
  • Sets clone to Thin provisioned disks
  • Works for live and cold clones
  • Runs Asynchronously so it will initiate multiple clones simultaneously
  • Ability to set parameters if you wish to target the clones to a different folder, datastore, or Thick disk.


I've used this function several times and has saved me a ton of time.  Hope it helps you as well.

Thanks

Josh

http://www.vtesseract.com/post/16447807254/clone-list-powercli-function

Attachments
Comments

Great function Josh, thanks for sharing.

Hi,

The script is really good. I'm planning to automate the process of deleting the clones as well. Could you please let me know a complete script which will delete the previous clones once the fresh clone is created. Appreciate your help in advance.

Cheers,

M

Hi Josh,

I am beginner in power CLI, I ran the scripts and it did not show any output likely because i need to supply a list of VMs which will be cloned. please let me know how to import of csv file as input. Please add that as part of script and share.

Thanks a bunch !

You'll note that the example provided on vTesseract.com is done by getting a list from a text file.  You could do similar with a CSV

Import-CSV <csvfile.csv> | Select <server-name-field> | Clone-List

I wasn't able to test this at the moment but something along these lines should work.

Sorry for the delayed response.  All of the clones get a prefix of "clone-"  you could potentially use that to have a list for deleting.

Version history
Revision #:
1 of 1
Last update:
‎01-24-2012 06:57 PM
Updated by: