Single line on how to get all your hosts and ip’s.
While very simple it’s been very handy to me, hope it helps you too!
Get-VMHost | Sort Name | Get-View | Select Name,@{N="IP Address";E={($_.Config.Network.Vnic | ? {$_.Device -like "vmk*"}).Spec.Ip.IpAddress}}
Sample output:
Name IP Address
---- ----------
CorkESXI10-1.vmware.com {111.35.30.10, 192.168.20.1}
CorkESXI10-2.vmware.com {111.35.30.11, 192.168.20.2}
CorkESXI10-3.vmware.com {111.35.30.12, 192.168.20.3}
CorkESXI10-4.vmware.com {111.35.30.13, 192.168.20.4}
Great, but i’m only interested in my VMK0 which is my management!
No problem
Get-VMHost | Sort Name | Get-View | Select Name,@{N="IP Address";E={($_.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}}