Hi
I know how to find old vmotions, is there a way to find active vmotions, I'm trying to write a script to rebalance or cluster between two ucs domains using drs rules, but I only want to do 8 at a time and wait for any active vmotions to finish.
You could do something like this.
It will stay in the While-loop while any vMotions are queued or running.
while (Get-View -Id $Taskmgr.RecentTask |
where { 'Running', 'Queued' -contains $_.Info.State -and
'VirtualMachine.relocate', 'Drm.ExecuteVMotionLRO' -contains $_.Info.DescriptionId })
{
sleep 1
$taskMgr.UpdateViewData()
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this.
It will stay in the While-loop while any vMotions are queued or running.
while (Get-View -Id $Taskmgr.RecentTask |
where { 'Running', 'Queued' -contains $_.Info.State -and
'VirtualMachine.relocate', 'Drm.ExecuteVMotionLRO' -contains $_.Info.DescriptionId })
{
sleep 1
$taskMgr.UpdateViewData()
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank LucD thats working well and it moving along quite quickly compared to my other tests. For anyone that sees this the full script I used was
$vms=Import-csv -UseCulture domain1vms.csv
foreach($vm in $vms)
{
$vm=Get-VM $vm.VMS
Set-DrsClusterGroup -DrsClusterGroup "UCS Domain 2 VMS" -VM $vm.Name -Add
Set-DrsClusterGroup -DrsClusterGroup "UCS Domain 1 VMS" -VM $vm.Name -Remove
$taskMgr = Get-View TaskManager
while (Get-View -Id $Taskmgr.RecentTask |where { 'Running', 'Queued' -contains $_.Info.State -and 'VirtualMachine.relocate', 'Drm.ExecuteVMotionLRO' -contains $_.Info.DescriptionId })
{
sleep 1
$taskMgr.UpdateViewData()
}
}