how do I specify cloning a new vm from a template based on certain location?
I have different datacenters and clusters and have templates based on their physical locations (cluster)
new-vm -Name xxx -vmhost xxx -Template yyyy
but it says I have multiple template with same names.
Do I need to have each template in each location with unique names?
You could do something like this:
New-VM -Name xxx -vmhost xxx -Template (get-cluster xxx | get-template yyyy)
Or:
New-VM -Name xxx -vmhost xxx -Template (get-datacenter qqq | get-cluster zzz | get-template yyyy)
That should be the idea anyway. It might be easiest to append or prefix the template names w/ location|cluster|orwhateveruniqueinfo.
Message was edited by: Zsoldier
I am getting this
We had mentions of this problem before.
Although the documentation states that Location can be a datacenter, cluster or folder, the cmdlet only seems to accept a datacenter or folder.
Which is logical I guess, templates are visible in the VMs and Templates view in the vSphere client, and there you only have datacenters and folders.
So I suspect this is a documentation error.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
There is a way to get the templates that are linked to a cluster.
Something like this
$morefs = Get-Cluster MyCluster | Get-VMHost | %{$_.ExtensionData.MoRef}
Get-Template | where {$morefs -contains $_.ExtensionData.Runtime.Host}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference