Automation

 View Only
  • 1.  Powercli deploy vm from Template - specify path of template

    Posted Jan 17, 2022 07:29 PM

    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?



  • 2.  RE: Powercli deploy vm from Template - specify path of template
    Best Answer

    Posted Jan 17, 2022 07:41 PM

    If that Foldername is unique, you can do

    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

    Note that you don't specify the hidden folder 'vm' in the Path