preloader
20 March 2013 / #Esxi #Powercli #Sdk

List of ESXi servers with their IP

Here is a little memento we forgot to post a while ago, in order to get name and IP of all ESXi servers. There are several ways of getting these data, you can use only vSphere SDK properties:

Get-View -ViewType HostSystem -Property Name,Config | Select Name, @{n="IP";e={$_.config.network.vnic.spec.ip.ipaddress}}

Or you can use DNS resolve:

Get-View -ViewType HostSystem -Property Name | Select Name, @{n="IP";e={[System.Net.Dns]::GetHostAddresses($_.Name)}}

Even if the results are the same, execution time differ widely. With ~200 serveurs ESXi, the vSphere SDK method takes around 26s to complete (even with the use of Property filter for the Get-View cmdlet) instead of 0,3s for the DNS one:

esxi_ip


> Frederic MARTIN