VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to limit VM limit for migration

Hi,

I am currently using below script to migrate VMs from one esxi to other, but the script is working fine but it is not limiting the vmotion limit to 2 even after specifying. it is migrating 3 VMs at a time. Am i missing anything, please help

$maxParallel = 2
$sourceesxi = "esx17"
$targetesxi = "esx16"
$vms = get-vmhost $sourceesxi | get-vm *
foreach($vm in $vms){
Move-VM -VM (Get-VM -Name $vm.name) -destination $targetesxi -RunAsync
do
{
sleep 5
} while((Get-Task -Status Running | where{$_.Name -eq 'RelocateVM_Task'}).Count -gt $maxParallel)
}

 

Reply
0 Kudos
1 Solution

Accepted Solutions
a_p_
Leadership
Leadership
Jump to solution

Replace -gt by -ge in the last line.

André

View solution in original post

Reply
0 Kudos
3 Replies
a_p_
Leadership
Leadership
Jump to solution

Replace -gt by -ge in the last line.

André

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Replace the -gt with a -ge


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

That worked. Thank you very much 🙂

Reply
0 Kudos