Created
September 28, 2019 03:36
-
-
Save tomoyk/b40ad88511831124e2d8efb792bba818 to your computer and use it in GitHub Desktop.
Get VM IP List by ESXi (Requirements: open-vm-tools)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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