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

This site uses Akismet to reduce spam. Learn how your comment data is processed.