Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pull an inventory of all ESXi VTEP virtual interfaces from all connected vCenter Servers
function Get-VMHostVtepInterface {
Gather VTEP interface inventory from all ESXi hosts
Gather VTEP interface inventory from all ESXi hosts.
This function was written with scale and speed in mind. It pull a host inventory using API calls and then unrolls API properties and
assigned them to a PSCustomObject.
Author: Kevin Kirkpatrick
Email: Kevin(at)vmotioned(dot)com
Version: 1.0
Updated: 8/10/16
Update Notes: 8/10/16
Write-Verbose -Message "[Get-VMHostVtepInterface] Gathering VMHost Inventory"
try {
$vmHostInventory = $null
$vmHostInventory = Get-View -ViewType HostSystem -Property Name,Config -ErrorAction 'Stop'
} catch {
throw "[Get-VMHostVtepInterface][ERROR] Could not gather VMHost inventory using 'Get-View'. $_"
} # end try/catch
} # end BEGIN block
foreach ($vmHost in $vmHostInventory) {
$vtepInterfaceQuery = $null
$vtepInterfaceQuery = $vmHost.Config.Network.Vnic | Where-Object {$_.Spec.NetStackInstanceKey -eq 'vxlan'}
$vmHostName = $null
$vmHostName = $vmHost.Name
[uri]$vCenter = $null
$vCenter = $vmHost.Client.ServiceUrl
Write-Verbose -Message "[Get-VMHostVtepInterface] Gathering VTEP VMkernel Interfaces for host {$vmHostName}"
foreach ($vtep in $vtepInterfaceQuery) {
$objVtepInt = @()
$objVtepInt = [PSCustomObject] @{
VMHost = $vmHostName
Interface = $vtep.Device
MacAddress = $vtep.Spec.Mac
IPv4Address = $vtep.Spec.Ip.IpAddress
SubnetMask = $vtep.Spec.Ip.SubnetMask
DHCP = $vtep.Spec.Ip.Dhcp
MTU = $vtep.Spec.Mtu
TsoEnabled = $vtep.Spec.TsoEnabled
NetworkStack = $vtep.Spec.NetStackInstanceKey
PinnedPnic = $vtep.Spec.PinnedPnic
vCenter = $vCenter.Host
} # end $objVtepInt
} # end foreach $vtep
} # end foreach $vmHost
} # end PROCESS block
Write-Verbose -Message "[Get-VMHostVtepInterface] Processing complete"
} # end END block
} # end function Get-VMHostVtepInterface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment