Get vMotion IP and vMotion Gateway through a PowerCLI
search cancel

Get vMotion IP and vMotion Gateway through a PowerCLI

book

Article ID: 375291

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

Retrieve IP and Gateway for the VMkernel with Enabled services equal to vMotion

Environment

vCenter server 7.x, 8.x

PowerCLI 12.x, 13.x

Resolution

PowerCLI script:

Connect-VIServer -Server "vCIP/FQDN" -User "username" -Password "password"

$vmhost =Get-VMHost -Name "host_name"

#Get vMotion IP

Get-VMHostNetworkAdapter -VMHost $VmHost -VMKernel  | select IP | where VMotionEnabled -eq $True

#Get vMotion Gateway

$networkConfig = Get-VMHostNetwork -VMHost $vmhost
$networkConfig.ExtensionData2.networkinfo.NetStackInstance | Where-Object {$_.Name -like "*vMotion*" } |  Select -ExpandProperty iprouteconfig | select DefaultGateway | Select -ExpandProperty DefaultGateway