Hi,
Below script sometimes hungs while executing, I need to hit enter in the CLI to resume sometimes. Please help, how can I overcome this.
$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 -ge $maxParallel)
}
Can you add the Verbose switch on the PowerCLI cmdlets?
That should perhaps tell you where the script is waiting with a prompt.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
you mean like this ?
$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 -verbose
do
{
sleep 5
} while((Get-Task -Status Running | where{$_.Name -eq 'RelocateVM_Task'}).Count -ge $maxParallel -verbose)
}
Yes, but on all the PowerCLI cmdlets (Get-Task, Get-VM, ...)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference