VMware Cloud Community
esxi1979
Expert
Expert

Catch failed vmotions

I would like to catch failed vmotions - typical err is, "

The vMotion migrations failed because the ESX hosts were not able to connect over the vMotion network. "

How shall i modify below ? thanks

Function Get-MotionDuration {

    $events = Get-VIEvent -Start (Get-Date).AddDays(-7)

    $relocates = $events |

        where {$_.GetType().Name -eq "TaskEvent" -and $_.Info.DescriptionId -eq "VirtualMachine.migrate" -or $_.Info.DescriptionId -eq "VirtualMachine.relocate"}

    foreach($task in $relocates){

        $tEvents = $events | where {$_.ChainId -eq $task.ChainId} |

            Sort-Object -Property CreatedTime

        if($tEvents.Count){

            New-Object PSObject -Property @{

                Name = $tEvents[0].Vm.Name

                Type = &{if($tEvents[0].Host.Name -eq $tEvents[-1].Host.Name){"svMotion"}else{"vMotion"}}

                StartTime = $tEvents[0].CreatedTime

                EndTime = $tEvents[-1].CreatedTime

                Duration = New-TimeSpan -Start $tEvents[0].CreatedTime -End $tEvents[-1].CreatedTime

            SourceHost = $tEvents[0].Host.Name

            DestinationHost = $tEvents[-1].Host.Name

            }

        }

    }

}

Connect-VIServer MyViServer –User Administrator –Password “Pa$$w0rd”

Get-MotionDuration | FT -AutoSize

0 Kudos
2 Replies
gopanaboena
Enthusiast
Enthusiast

Hi

Is it working without script?

Venkat

0 Kudos
esxi1979
Expert
Expert

Sorry what u mean here ?

0 Kudos