Actually I found the answer in one of your other posts Luc. Thanks for being so helpful! :smileyhappy:
Change the ###### below to your VirtualCenter Servers FQDN
Connect-VIServer -Server ###### -Protocol https | out-file $PHP_CloneLog -Append -Encoding "ASCII"
Function CreateNewClone #Must be passed 6 agruments (<VM to Clone>,<New Clone Name>,<Server[Host/VC]>,<DataStore Name>,<Folder>,<ResourcePool>)
{
$vm2c = $args[0] #Name of the virtual to be cloned.
$destcln = $args[1] #Name of the clone to be made.
$erver = $args[2] #Name of the host or virtual center server.
$destdatastr = $args[3] #Name of the destination datastore to which the new clone will be deployed (Optional).
$foldername = $args[4] #Name of the destinaion folder for the clone.
$resourcepool = $args[5] #Name of the destination Resource Pool for the clone.
"{0} Initializing clone task for: $vm2c >>-->> $destcln" -f ::Now | out-file $PHP_Clonelog -Append -Encoding "ASCII"
" Using DataStore named: $destdatastr" -f ::Now | out-file $PHP_Clonelog -Append -Encoding "ASCII"
" Using ResourcePool named: $resourcepool" -f ::Now | out-file $PHP_Clonelog -Append -Encoding "ASCII"
$serv = Connect-VIServer -Server $erver -Protocol https
Write-Host "Server" $serv
$FolderID = Get-Folder -Name $foldername #-Server $serv
Write-Host "FolderID" $FolderID
$targetfolder = get-view ($FolderID).ID
Write-Host "targetfolder" $targetfolder.ID
$destdsview = get-view (get-datastore -name $destdatastr).id
Write-Host "destdsview" $destdsview.ID
$destpool = Get-View (Get-ResourcePool -Name $resourcepool).id
$VMCloneSpec = New-Object VMware.Vim.VirtualMachineCloneSpec
$VMCloneSpec.Location = New-Object VMware.Vim.VirtualMachineRelocateSpec
$VMCloneSpec.location.datastore = $destdsview.moref
$VMCloneSpec.location.pool = $destpool.moref
$VMCloneSpec.powerOn = $false
$VMCloneSpec.template = $false
$clntask = (Get-View (Get-VM -Name $vm2c).ID).CloneVM_Task($targetfolder.MoRef, $destcln, $VMCloneSpec)
$task = Get-View $clntask
Write-Host "State: " $task.Info.State
while ($task.Info.State -eq "running" -or $task.Info.State -eq "queued")
{
$task = Get-View $clntask
Write-Host "Waiting"
}
$clntask | out-file $PHP_CloneLog -Append -Encoding "ASCII"
############################################################################
}