Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wangwenchao/98207bcdcb0d946aa4673634073857c5 to your computer and use it in GitHub Desktop.
Save wangwenchao/98207bcdcb0d946aa4673634073857c5 to your computer and use it in GitHub Desktop.
ESXi: get the IP address of a host running VMware tools
#!/bin/bash
vim-cmd vmsvc/getallvms | grep -i hostname | cut -d ' ' -f 1 | xargs vim-cmd vmsvc/get.guest | grep ipAddress | sed -n 1p | cut -d '"' -f 2
# or
ssh esxi.example.com /bin/vim-cmd vmsvc/get.guest $(ssh esxi.example.com /bin/vim-cmd vmsvc/getallvms | grep -i hostname | cut -d ' ' -f 1) | grep ipAddress | sed -n 1p | cut -d '"' -f 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment