Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

asked on

Create a VM with powercli and place it in a resource pool

$resourcePool = (Get-Datacenter "Datacenter" | Get-Cluster -Name $cluster | Get-Resourcepool -name Prod)
Get-Cluster $cluster | New-VM -Name $vmname -DiskStorageFormat $DiskStorageFormat -Template $vmtemplate -ResourcePool $resourcePool

Open in new window


I get:

New-VM : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

So how do I create this VM and specify the correct resource pool in the correct cluster? Using the resource pool name is no good idea, there are several clusters with the same resource pool names. Can't find any information on how to get the vicontainer and pass it as an argument.
ASKER CERTIFIED SOLUTION
Avatar of Mazdajai
Mazdajai
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

ASKER

The last line actually became this:
New-VM -Name $vmname -DiskStorageFormat $DiskStorageFormat -Template $vmtemplate -ResourcePool $resourcePool -VMHost (((get-cluster $cluster) | get-vmhost)[0]).Name