VMware Cloud Community
elihuj
Enthusiast
Enthusiast
Jump to solution

Clone VM Script

I'm looking to create a PowerCLI script to clone a VM, and overwrite any existing clones that are present. Just doing some searching, here is what I found:

New-VM -Name VM2 -VM VM1 -Datastore datastorename -vmhost hostname

I have not tested the script yet, but it does look like it will do at least part of what I am looking to accomplish. Do I need to use the Datastore and VMhost parameters? And is there anything I can do to delete any existing clones before the script is run? Thank you.

40 Replies
LucD
Leadership
Leadership
Jump to solution

Does that work when you something similar to this?

Note, that is an example, not a complete vMotion script

$vm = Get-VM -Name MyVM -Server vc1

$destination = Get-Cluster -Name MyCluster -Server vc2

Move-VM -VM $vm -Destination $destination


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos