hello community
variables:
$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
colin
Are you connected to multiple vCenters, or are your vCenters configured in LinkedMode?
Try adding the Server parameter on the cmdlets, that way you can specify exactly which resource on which vCenter you want to retrieve.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi there
2 vcenter in linked mode yes, but that's not the problem as i connect-viserver to one vcenter server.
i have 2 cluster with a resourcepool called 'abc' (customername) on one vcenter
and 2 datacenter with a vm-folder called 'abc' (customername) on the same vcenter server
if the linked vcenter mode would be a problem, get-resourcepool -name $customer would result in 4 resourcepools due to the other vcenter is a "mirror" of the first.
Then you can retrieve the correct ones by starting from the top of the path.
$folder = Get-Datacenter -Name <dc> | Get-Folder -Name 'abc'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference