«

»

List VMware ESXi vMotion Enabled VMkernel Interfaces Using PowerCLI

A while back during a troubleshooting exercise I created a script to list ESXi host VMKernel Interfaces (vmk) with vMotion enabled since some of the ESXi hosts had vMotion enabled on multiple interfaces. The below information is included per ESXi hosts in the script output CSV file:

  • VMHost – ESXi host Name
  • IP – IP address configured for the VMkernerl Interface (vmk) where vMotion is enabled
  • SubNetMask – Subnet mask configured for the VMkernerl Interface (vmk) where vMotion is enabled
  • PortGroupName – The vSphere VSS or VDS port group the vmk is attached to
  • DeviceName – vmk name
  • VMotionEnabled – Script looking for VMotionEnabled set to True.

The script that was tested using the following software versions:

  • VMware vCenter Server 6.5
  • VMware ESXi 6.5 build 5146846
  • VMware PowerCLI 6.5 Release 1 build 4624819
# PowerCLI script to list VMware ESXi vMotion Enabled VMkernel Interfaces
# Version 1.0
# Magnus Andersson – Sr Staff Solution Architect @Nutanix
#
#
# ---------------------------------------------------
# Edit the information below to match your environment
#
# Specify vCenter Server(s), vCenter Server username, vCenter Server user password.
$vCenterServers=("vcenter01.vcdx56.local","vcenter02.vcdx56.local")
$vCenterUser="magander@vcdx56"
$vCenterUserPassword="not-secret"
#
# Specify script output file name and location on the workstation where you run the script
$outfile="c:\scripts\output\EnabledVMkernelInterfaces.csv"
#
# You don't have to change anything below this line
# ---------------------------------------------------
#
#
foreach ($vCenterServer in $vCenterServers) {
# Connect to vCenter Server
write-host Connecting to vCenter Server $vcenterserver -foreground green
Connect-viserver $vCenterServer -user $vCenterUser -password $vCenterUserPassword -WarningAction 0 | out-null
Get-VMHost * | sort | Get-VMHostNetworkAdapter -VMKernel | select VMHost,IP,SubNetMask,PortGroupName,DeviceName,VMotionEnabled | where VMotionEnabled -eq $True | Export-Csv $outfile -Append
# Disconnect from vCenter Server
write-host "Disconnecting to vCenter Server $vCenterServer" -foreground green
disconnect-viserver -confirm:$false | out-null
echo ""
}

Below are the 26 first ESXi hosts vMotion configuration

When vMotion is enabled on multiple VMKs there will be one line per VMK interface per ESXi host.

Below is the powercli script screen output which is not that much 🙂

Happy PowerCLI scripting