itnifl
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
New-VM -Name $vmname -DiskStorageFormat $DiskStorageFormat -Template $vmtemplate -ResourcePool $resourcePool -VMHost (((get-cluster $cluster) | get-vmhost)[0]).Name