≡ Menu

PowerShell: Get observed IP Ranges of ESX host

In VMware, Observed IP Range means the list of IP addresses subnets a ESX host can see and their VLAN IDs. ESX host gets this information from the switch to which it is connected using CDP protocol. If the switch doesn’t allow CDP information advertizement then you will not see this information.

In this post, I will show you how to query list of IP ranges a ESX host can see and their VLAN IDs information using PowerShell for a given ESX host(prodesx1.techibee.com). This information you can get from UI as well in the network adapter section of the configuration tab of ESX host.

You need to execute these commands from PowerCLI as the code involves VMware Cmdlets.

First we need to query ESX host obj.

$VMhostobj = Get-VMHost -Name prodesx1.techibee.com

Once you have the VMHost object, we need to get the view of it and then query network adapter configuration view.

$VMHostView = Get-View $VMHostObj            
$networkView = Get-View $VMHostView.ConfigManager.NetworkSystem

This view will contain the network information which shows the physical network adapters that contain the CDP information. So, we need query each adapters CDP information using QueryNetworkHint() method

$physicalnics = $networkview.networkinfo.pnic            
foreach($nic in $physicalnics) {            
    $hints = $networkview.querynetworkhint($nic.device)            
    foreach($hint in $hints) {            


The $hint variable in above code contains several other information like switch port the ESX host connected, name of the switch etc. This contains the information that you see from Virtual Center UI.

I derived this code with inspiration from VMware KB article http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1007069 . it is the source for above image as well.

{ 0 comments… add one }

Leave a Comment