Last active
October 31, 2023 09:08
-
-
Save alexclifford/9822297 to your computer and use it in GitHub Desktop.
ESXi: get the IP address of a host running VMware tools
This file contains hidden or 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
#!/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
How are you getting that to work? Busybox supports neither grep's -w or -x commands? Did you install a 3rd party grep?