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)
}
Replace -gt by -ge in the last line.
André
Replace the -gt with a -ge
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked. Thank you very much 🙂