Automation

 View Only
  • 1.  Deploy from template gets error: 'Location' expects a single value

    Posted Nov 15, 2018 07:05 PM

    I have one vCenter server with multiple clusters as described below...

    yomama

    jomama

    Each cluster has a bunch of folders and they BOTH have the folder called 'Discovered virtual machine'.

    I need to deploy my VM from a template but I need to target the specific cluster but when I try the below command.....

    New-VM -Name doooofus -Template win2016x64 -Datastore superdoooperfast_ssd -Location "Discovered virtual machine" -ResourcePool yomama -DiskStorageFormat Thin

    I get the below message....

    "The specified parameter 'Location' expects a single value, but your name

    criteria 'Discovered virtual machine' corresponds to multiple values."

    But the VM deploys BUT it is in the root of the cluster.

    How do I tell it explicitly what cluster to put my vm in and put it in the folder called 'Discovered virtual machine' in that specific cluster?

    Thanks



  • 2.  RE: Deploy from template gets error: 'Location' expects a single value

    Posted Nov 15, 2018 07:36 PM

    The "Discovered virtual machine" folder is normally created under a datacenter, not a cluster.

    Do you have those 2 clusters in 2 different datacenters?



  • 3.  RE: Deploy from template gets error: 'Location' expects a single value

    Posted Nov 15, 2018 07:41 PM

    "Do you have those 2 clusters in 2 different datacenters?"

    Yes. In different Geo Locations.



  • 4.  RE: Deploy from template gets error: 'Location' expects a single value
    Best Answer

    Posted Nov 15, 2018 08:43 PM

    Try like this

    $clusterName = '<clustername>'

    $folder = Get-CLuster -Name $clusterName | Get-Datacenter |

       Get-Folder -Name 'Discovered virtual machine'

    New-VM -Name doooofus -Template win2016x64 -Datastore superdoooperfast_ssd -Location $folder -ResourcePool yomama -DiskStorageFormat Thin



  • 5.  RE: Deploy from template gets error: 'Location' expects a single value

    Posted Nov 15, 2018 10:03 PM

    Thank you sir! That did it.

    I wanted it one liner so I made like this.....

    New-VM -Name doooofus -Template 'win2016x64' -Datastore 'superdoooperfast_ssd' -Location (Get-Cluster -Name 'yomama' | Get-Datacenter | Get-Folder -Name 'Discovered virtual machine') -ResourcePool 'yomama' -DiskStorageFormat Thin

    Works. Thanks again!