Automation

 View Only
  • 1.  Few questions about VI Toolkit

    Posted Dec 09, 2008 09:47 AM

    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



  • 2.  RE: Few questions about VI Toolkit

    Posted Dec 09, 2008 10:47 AM

    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>
    }
    



  • 3.  RE: Few questions about VI Toolkit

    Posted Dec 14, 2008 09:43 AM

    Hi,

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

    Should I use its ID instead?



  • 4.  RE: Few questions about VI Toolkit

    Posted Dec 14, 2008 05:47 PM

    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