Skip to content

Instantly share code, notes, and snippets.

@tomoyk
Created September 28, 2019 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyk/b40ad88511831124e2d8efb792bba818 to your computer and use it in GitHub Desktop.
Save tomoyk/b40ad88511831124e2d8efb792bba818 to your computer and use it in GitHub Desktop.
Get VM IP List by ESXi (Requirements: open-vm-tools)
VM_LIST=`vim-cmd vmsvc/getallvms | awk '{print $1"/"$2}'`
# filter: using `grep`
for vm in $VM_LIST
do
vm_id=`echo $vm | cut -f1 -d'/'`
ip_addr=`vim-cmd vmsvc/get.summary $vm_id | grep ipAddress | grep -o "10.1.1.[0-9]\+"`
vm_name=`echo $vm | cut -f2 -d'/'`
echo $vm_name $ip_addr
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment