Is this possible to do?
I am doing the following.
$TempSource = Get-Template -Name $Temps.Name -Location "SrcTemplates" -Server "vcenter1"
New-VM -Name "template" -Template $TempSource -ResourcePool "cluster" -Datastore "datastore" -Location "templates" -Server "vcenter2" -RunAsync
Whenever I run this, it starts a clone from a running VM that in the destinations vCenter. I'm trying to find a better alternative to syncing templates across locations since the content library isn't working the way it should.
Not too sure I understand what you mean by
it starts a clone from a running VM that in the destinations vCenter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Expected result:
Clone task is created using template from vCenter1 for VM being created in vCenter 2
Actual result:
Clone task is created using a running VM as clone source in vCenter 2 for VM being created in vCenter 2
Does this mean you have VMs with the same DisplayName in vCenter1 and vCenter2?
If yes, use a Get-VM with the Server parameter pointing to vCenter1, to get the source in a variable (let's say $vm).
Then use that variable $vm on the VM parameter of the New-VM cmdlet.
I suspect that if you use Object By Name see about_obn), that it takes the VM in vCenter2.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, they have different names. One is a template in vCenter1 and I use $TempSource = Get-Template -Name templatename -Location "SrcTemplates" -Server "vcenter1"
the resulting command acts like I’m using Get-VM on a VM in vCenter 2, with a completely separate name. I’m not even using -VM in the New-VM command which would be used to specify a VM to clone from.
Is this with the latest PowerCLI version?
In any case, you might be better off to open an SR, this sounds like a "feature".
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yeah this is the latest PowerCLI version. Are you aware of a way to move templates between vCenters that are linked with PowerCLI? I can do it through the GUI, but with the volume of templates and locations they need to be synced to it is very time consuming. Content library (OVF) doesn’t work well with using RunASync and for whatever reason using the VMTX format in content library is unreliable when syncing between locations.
I used this one in the past, see Re: Mware -clone to template (from template) powercli
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference