Virtually everything is poshable
PowerCLI: One-Liners Checking Host Network Information
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 |
| Print article | This entry was posted by Virtu-Al on September 21, 2009 at 12:39, and is filed under PowerCLI, powershell, vmware. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |







(3)
(13)
(0)