• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1859
  • Last Modified:

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.
1 Solution
There is no cluster option in New-VM cmedlet, use -VMhost instead.

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

Open in new window

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

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now