VMware Cloud Community
yanivamrami
Enthusiast
Enthusiast

Few questions about VI Toolkit

Hi,

I am new to the VMWARE VI Toolkit and I have few questions:

1. I am trying to deploy a VM from template and I am trying to run the following command:

New-VM -VMHost -Template vm2003 -RunAsync

I get the following error:

New-VM : 12/9/2008 11:39:21 AM New-VM The specified parameter 'ResourcePool' expects a single value, but your name criteria 'Res Pol' corresponds to multiple values.

My Resource Pool has space in it.

Note that my Folder Name has space as well but it is working.

2. How can I run for loop (or other loops) from the toolkit window?

Thank you,

Yaniv

Please rate helpful / correct answers. Thank you
0 Kudos
3 Replies
LucD
Leadership
Leadership

1) You can have blanks in resource pool names.

How many objects are returned when you do

Get-ResourcePool "Res Pol"

Do you have resource pools with the same name in different clusters ?

2) You can use the the for

for ($i=0; $i -lt 10; $i++){
    <your commands>
}

or the foreach loop

$collection = (1,2,3,4,5)
foreach ($element in $collection){
    <your commands>
}


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

0 Kudos
yanivamrami
Enthusiast
Enthusiast

Hi,

Yes, I have the same name for Resource Pools on different clusters?

Should I use its ID instead?

Please rate helpful / correct answers. Thank you
0 Kudos
LucD
Leadership
Leadership

No, you can't use the Id for the -ResourcePool parameter.

But you can "pipe" the resourcepoolname to the New-VM cmdlet.

That gives you the option to select the resourcepool you want.

Something like this for example

Get-Cluster <cluster-name> | `
  Get-ResourcePool <resourcepool-name> | `
  New-VM -VMHost <ESX_HOSTNAME> -NAME <VM_NAME> -Location "Folder Name" -Datastore <LUNxx> -Template vm2003 -RunAsync


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