This script lets you clone a VM using PowerShell.
source: https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Clone-VM-with-powershell/td-p/2103930
1
2
3
4
5
6
7
8
9
10
11
12
13
$fromVMname = "Alpine"
$newVMName = "Adam2"
$tgtEsxName = "something" # Host IP or FQDN
$tgtDatastoreName = "SSD"
$vCenter = "something" # vCenter IP of FQDN
$vCUser = "administrator@vsphere.local"
$vCPW = "password"
Connect-VIServer $vCenter -User $vCUser -Password $vCPW -Force | Out-Null
New-VM -Name $newVMName -VM (Get-VM $fromVMname) -VMHost (Get-VMHost $tgtEsxName) `
-Datastore (Get-Datastore $tgtDatastoreName) | Out-Null