bshell
Enthusiast
Enthusiast

Assigning a VM to a Resource Pool

I can't seem to get this working for a cluster. It works if the Resource Pool is on a Host, but not a cluster.

I get this error

PS C:\Documents and Settings\Manager\Desktop> Get-VM myvm | Move-VM -Destination (Get-ResourcePool Lab_High)

Move-VM : Destination is a Resource Pool owned by a Cluster. Please select for destination a Host in that Cluster or a Resource Pool owned

by a stanalone Host

At line:1 char:30

+ Get-VM myvm | Move-VM <<<< -Destination (Get-ResourcePool Lab_High)

Not sure why it cares its Cluster RP.

0 Kudos
2 Replies
rfoust
Contributor
Contributor

Hmm... I just tested the same command and get the same error.

0 Kudos
admin
Immortal
Immortal

The developers have confirmed that this is a bug with the current toolkit. In case anyone's curious, below I've posted how you could do this using managed objects. I tested this and confirmed that it works for resource pools owned by clusters.

  1. Move a virtual machine to a given resource pool.
    $hostName = "<host>"
    $userName = "<user>"
    $password = "<password>"
    $vmName = "<vmname>"
    $poolName = "<poolname>"
    #
    # Connect to the ESX server.
    connect-vim -url

[ https://$hostName/sdk|https://$hostname/sdk] -username $userName -password $password
#
# Build a filter to specify a specific virtual machine.
$vmFilter = new-object System.Collections.Specialized.NameValueCollection
$vmFilter.Add("name", $vmName)
#
# Get the VM we want to move.
$vm = find-entityview -viewtype VirtualMachine -filter $vmFilter
#
# Now a filter for the pool.
$poolFilter = new-object System.Collections.Specialized.NameValueCollection
$poolFilter.Add("name", $poolName)
#
# Get the pool.
$pool = find-entityview -viewtype ResourcePool -filter $poolFilter
#
# Move the VM in.
$pool.MoveIntoResourcePool($vm.MoRef)

Carter

0 Kudos