Sometimes as a consultant when performing an initial look or a healthcheck on a new system you will want to confirm all hosts have the correct network information, if there is a mis-configured vmotion portgroup or something similar then this could impact HA or if there is an incorrect DNS server then this may also have issues further down the line with your service console.
The following quick one-liners display some vital information for each host, errors can be seen at a glance, rather than checking each host individually, for us to gain this information we use the wonderful Get-VMHostNetwork cmdlet and expand a few areas of interest:
- Remember these can be narrowed down further by adding the Get-Cluster “MyCluster” | to the start of the line.
- Also remember this information can also be exported to a csv by adding | Export-csv “C:\info.csv” to the end of the line.
To list all ESX Hosts and their Service console information:
Get-VMHost | Get-VMHostNetwork | Select Hostname, ConsoleGateway, DNSAddress -ExpandProperty ConsoleNic | Select Hostname, PortGroupName, IP, SubnetMask, ConsoleGateway, DNSAddress, Devicename
HostName | PortGroupName | IP | SubnetMask | ConsoleGateway | DNS Address | DeviceName |
esx01 | SC | 192.168.2.33 | 255.255.255.0 | 192.168.2.1 | 192.168.2.20 192.168.1.20 | vswif0 |
esx01 | SC 2 | 192.168.3.43 | 255.255.255.0 | 192.168.2.1 | 192.168.2.20 192.168.1.20 | vswif1 |
esx02 | SC | 192.168.1.12 | 255.255.255.0 | 192.168.1.254 | 192.168.1.20 | vswif0 |
esx03 | SC | 192.168.2.34 | 255.255.255.0 | 192.168.2.1 | 192.168.2.20 192.168.1.20 | vswif0 |
esx03 | SC 2 | 192.168.3.44 | 255.255.255.0 | 192.168.2.1 | 192.168.2.20 192.168.1.20 | vswif1 |
To list all ESX Hosts and their VMotion Enabled Networks information:
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMkernelGateway -ExpandProperty VirtualNic | Where {$_.VMotionEnabled} | Select Hostname, PortGroupName, IP, SubnetMask, VMkernelGateway, Devicename
HostName | PortGroupName | IP | SubnetMask | VMKernelGateway | DeviceName |
esx01 | VMkernel | 192.168.3.33 | 255.255.255.0 | vmk0 | |
esx02 | VMkernel | 192.168.3.34 | 255.255.255.0 | 192.168.3.1 | vmk0 |
Nearly 10 years later and this still works well. Thanks Alan!
Thanks for this script
Is their any script which can run simultaneously on all the esx host at one time rather then running on one by esx host what all defined in CSV.
Get-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.ManagementTrafficEnabled} | Select Hostname, PortGroupName, IP, SubnetMask will get most of that info but not the configured DNS address.
I have the same issue. Maybe “ConsoleNic” finally got a vacation. There do seem to be some information in the Get-VMHostNetworkAdapter feature, like…
Get-VMHost | Get-VMHostNetworkAdapter|select *
.. with some testing and trying this might be usefull.
Hmm, No output for me (PowerCLI v5.1):
Get-VMHost | Get-VMHostNetwork | Select Hostname, ConsoleGateway, DNSAddress -ExpandProperty ConsoleNic | Select Hostname, PortGroupName, IP, SubnetMask, ConsoleGateway, DNSAddress, Devicename
But how do you list the Default Gateway, SubnetMask and DNS for each Virtual Machine
Pingback: Documenting Environment Settings with PowerCLI
Hello, we have ESXi5 and with this command, i get no result. I’m connect to my VCenter Server
Hello ,
I really want to see:
PortGroupName:
IP:
Mask:
Gate:
VLAN:
Any ideas how to get VLAN and put it in same table.
Something like that:
$vm = get-vmhost 192.168.0.13
$net = $vm | Get-VirtualPortGroup
$net | Select-Object Name, VLanId | Format-Table -auto
$net2 = $net | Select-Object Name,IP,SubnetMask,Mac | ft -auto
This is not actually an error just a warning that in future versions the ConsoleNic property of this object may be made obsolete.
I’m getting this error…………….
[vSphere PowerCLI] C:\> Get-VMHost | Get-VMHostNetwork | Select Hostname, ConsoleGateway, DNSAddress -ExpandProperty ConsoleN
ic | Select Hostname, PortGroupName, IP, SubnetMask, ConsoleGateway, DNSAddress, Devicename
WARNING: ‘ConsoleNic’ property is obsolete. Use ‘Get-VMHostNetworkAdapter’ cmdlet instead.