A quick PowerCLI oneliner to get the network configuration of each ESXi host

Some time ago I had to find out the configured IP addresses of all VMkernel ports of all ESXi hosts in an environment because of a new IP subnet that had to be implemented.

Using the following oneliner, I was able to get the IP addresses of each VMkernel port quickly using PowerCLI:


Get-VMHost | Get-VMHostNetwork | Select Hostname, VMkernelGateway -ExpandProperty VirtualNic | Select Hostname, PortGroupName, IP, SubnetMask, VMkernelGateway, Devicename

If you want to find out only the VMkernel ports connected to a specific Port Group, you can add the ‘where {$_. part ‘ where vxw-vmknicPg-dvs-30-999 is the Port Group name, in my case VXLAN transport network, as shown below:


Get-VMHost | Get-VMHostNetwork | Select Hostname, VMkernelGateway -ExpandProperty VirtualNic | where {$_.PortGroupName -match "vxw-vmknicPg-dvs-30-999"} | Select Hostname, PortGroupName, IP, SubnetMask, VMkernelGateway, Devicename

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s