VMware Cloud Community
COS
Expert
Expert
Jump to solution

Deploy from template gets error: 'Location' expects a single value

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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

Do you have those 2 clusters in 2 different datacenters?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
COS
Expert
Expert
Jump to solution

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

Yes. In different Geo Locations.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
COS
Expert
Expert
Jump to solution

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!

0 Kudos