3 Replies Latest reply on Nov 11, 2019 4:39 AM by LucD

    move-vm to specific resourcepool and vm-folder

    colinwagenaar Lurker

      hello community




      $Customer = 'abc'

      $VMName = 'xyz'

      $ResourcePool = (Get-ResourcePool -Location (Get-VM -Name $VMName | Get-Cluster) | Where-Object {$_.Name -eq $Customer}).Id

      $VMFolder = (Get-Folder -location (Get-VM -name $vmname | Get-Datacenter) | Where-Object {$_.Name -eq $Customer}).Id

      $Cluster = Get-VM -Name $VMName | Get-Cluster

      $Datacenter = Get-VM -Name $VMName | Get-Datacenter


      the move-vm command to a resourcepool/folder fails with following error, because we have multiple vm-folders and resourcepools with the same name in different clusters and datacenter.


      The specified parameter 'InventoryLocation' expects a single value, but your name criteria 'GCS' corresponds to multiple values.


      so i tried it with the unique .id value witout success:

      Move-VM -VM $VMName -InventoryLocation $Customer | Where-Object {$_.Id -eq $ResourcePool}

      Move-VM -VM $VMName -InventoryLocation $Customer | Where-Object {$_.Id -eq $VMFolder}


      the command works without errors. in vcenter i see the resource move, but nothing happens with the vm.

      what am i missing? also tried with cluster and datacenter inputs

      thank you very much for your help