Posted By

seanboycegmailcom on 07/21/10


Tagged

vmid


Versions (?)

Get vmid of ESX(i), VSphere virtual machine


 / Published in: Bash
 

Gets the vmid of the virtual machine. The first and only argument is the .vmx config file.

  1. #!/bin/bash
  2.  
  3. if [ $# -ne 1 ]; then
  4. echo Usage: `basename $0` [VMX FILE]
  5. echo Get vmid of virtual infrastructure virtual machine
  6. echo
  7. echo Parameter expected 1>&2
  8. exit 65
  9. fi
  10.  
  11. if [ ! -s $1 ]; then
  12. echo Virtual machine does not exist or is empty.
  13. exit 1
  14. fi
  15.  
  16. /usr/bin/vmware-cmd "$1" getid | cut -d' ' -f3
  17. exit $?

Report this snippet  

You need to login to post a comment.