Automation

 View Only
  • 1.  how to build a new vm based on cluster with powercli?

    Posted Nov 06, 2014 03:19 AM

    when you create a new vm on cluster in the GUI, you can't select host, it is decided by the cluster.

    Now I want to create a new vm on cluster by powerCli. I haven't found any parameter to specify the cluster.

    Only the 'VMHost' to specify the host.

    why they are so different?

    Any one can help me to understand it and how to create a new VM on cluster?

    Thank you in advance!



  • 2.  RE: how to build a new vm based on cluster with powercli?
    Best Answer

    Posted Nov 06, 2014 04:26 AM

    Hello, bob1118-

    While, like you said, there is no -Cluster parameter to the New-VM cmdlet, you _can_ effectively specify the cluster at new VM creation time via PowerCLI:  you specify the resource pool within the desired cluster.  So, a partial New-VM call would look like:

    New-VM -Name myNewVM0 -ResourcePool (Get-Cluster myDestinationCluster | Get-ResourcePool -Name "Resources") -Template ...

    That uses the default "Resources" resource pool that exists in any cluster.  And, you would populate the rest of the pertinent parameters to make the new VM of your desires.  How does that do?



  • 3.  RE: how to build a new vm based on cluster with powercli?

    Posted Nov 06, 2014 05:42 AM

    hello mattboren,

    your answer really helps, thank you very much!

    but i still have one point unclear. What if i use both -VMHost and -ResourcePool, BUT... they have conflicts?

    for example:

    if the DataCenter has two Cluster

    Cluster1 has three hosts: host1, host2, host3, and resourcepool1, resourcepool2

    Cluster2 has two hosts: host4, host5, and resourcepool3

    if I run:

    New-VM -VMHost host1 -ResourcePool resourcepool1 ...

    it should be OK.

    what if I run

    New-VM -VMHost host1 -ResourcePool resourcepool3 ...

    ?

    will it report error?

    Sorry, my env only has one cluster, i can't test on 2nd situation.

    I will be very appreciated if you can help.



  • 4.  RE: how to build a new vm based on cluster with powercli?

    Posted Nov 07, 2014 03:29 AM

    Hello, bob1118-

    If you run that second command (that uses a Resource Pool from one cluster and a VMHost from another cluster), you should receive an error.


    I verified, and such a command returned the error "A specified parameter was not correct.".  Now we know.



  • 5.  RE: how to build a new vm based on cluster with powercli?

    Posted Nov 07, 2014 03:56 AM

    Thank you very much for your answer. :smileygrin: