I tried to find ip addresses assigned to vms in an esxi server? either from terminal or vSphere Client.
4 Answers
If you have installed VMware Tools in the VMs, then you can use the following one-liner to get the IP Address from command line:
for i in `vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1}'`; do vim-cmd vmsvc/get.guest $i | grep -i 'ipaddress = "'; done
For non-shell, you have tons of powercli snippets, but you still need VMware tools.

- 112
- 7
-
Here's a cleaner version of the above that doesn't pull in extraneous IPs like default routers, DNS, etc.: ```vim-cmd vmsvc/getallvms | grep "^[[:digit:]]" | awk '{print $1":"$2}' | while read vm; do num=${vm%:*}; name=${vm#*:}; printf "%3d %s " $num $name; printf "`vim-cmd vmsvc/get.guest $num | awk 'BEGIN{l=""}{if(l && $0~/ipAddress =/ && match($0,/[0-9.]{7,15}/)){print substr($0,RSTART,RLENGTH)}if($0~/IpConfigInfo.IpAddress/){l=$0}else{l=""}}' | sort -un | xargs`"; printf "\n"; done``` – Scott Mar 14 '23 at 06:06
Check the last box on the following link for a couple options: https://kb.vmware.com/kb/2012964
Depending on which version of ESXi you're using, you should be able to right click within the GUI and add a column for IP address.
Note: in order for the IP addresses of guests to be presented up through the ESXi host, VMware Tools will need to be installed and running.

- 1,886
- 1
- 7
- 5
v = Get-View -Viewtype VirtualMachine -Property name, guest.ipaddress
$report = @()
foreach($vm in $v)
{
$list = '' | select name, ipaddress
$list.name = $vm.name
$list.ipaddress = $vm.guest.ipaddress
$report += $list
}
$report | export-csv c:\temp\listallnamesandipaddresses.csv

- 1,016
- 1
- 8
- 18
-
That answer could use some context. Like what language that even is and where/how to use it. – con-f-use Mar 25 '23 at 17:27
One can connect to vcenter(comes with vsphere) using powershell(C#) and Powercli module installed in powershell. You can firstly connect to vcenter using this command:
Connect-VIServer $vCenter
Then to list out all VM hosted on added esxi host on vcenter use this command:
Get-VM | Select Name, @{N="IP Address";E={@($_.guest.IPAddress[0])}}

- 1
- 4