Trying to deploy a VM from template using power cli using this:
New-VM -Name $vmname -Template $template -Datastore $datastore -ResourcePool $cluster -ErrorAction stop
The issue is I have templates with the same name in various folders in my vcenter. When I specify the path to the template in the command above, I get "Could not find Template with name datacenter/vm/Linux8template"
Any ideas on how I could specify the path to the template in the command above?
If that Foldername is unique, you can do
$template = Get-Folder -Name <foldername> | Get-Template -Name Linux8template
If that is not the case, you can get the folder object by using my Get-FolderByPath function.
Once you have that you can use the Get-Template with the Location parameter
$folder = Get-FolderByPath -Path 'datacenter/<foldername>
Get-Template -Name Linux8template -Location $folder
Note that you don't specify the hidden folder 'vm' in the Path
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If that Foldername is unique, you can do
$template = Get-Folder -Name <foldername> | Get-Template -Name Linux8template
If that is not the case, you can get the folder object by using my Get-FolderByPath function.
Once you have that you can use the Get-Template with the Location parameter
$folder = Get-FolderByPath -Path 'datacenter/<foldername>
Get-Template -Name Linux8template -Location $folder
Note that you don't specify the hidden folder 'vm' in the Path
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference