Powered by Blogger.

ESX4 - How do I turn on/off a Virtual Machine from the command line ?

sing the vmware-cmd command you can perform a number of actions on your Virtual Machines from the command line.

Below shows you some of the functions you can perform :

List Virtual Machines

[root@ESX4 ~]# vmware-cmd -l
/vmfs/volumes/4c16a0ec-2c7ebe2a-6ad5-0011s8azz71c/OpenSolaris 2009.06/OpenSolaris 2009.06.vmx
/vmfs/volumes/4c16a0ec-2c7ebe2a-6ad5-0011s8azz71c/CentOS 5 - Oracle/CentOS 5 - Oracle.vmx
/vmfs/volumes/4c16a0ec-2c7ebe2a-6ad5-0011s8azz71c/CentOS 5a/CentOS 5a.vmx

Turn On Virtual Machine

Below shows you how to start a virtual machine, to stop it just change the start command for stop.

[root@ESX4 ~]# vmware-cmd "/vmfs/volumes/4c16a0ec-2c7ebe2a-6ad5-0011s8azz71c/OpenSolaris 2009.06/OpenSolaris 2009.06.vmx" start
start() = 1

List Virtual Machine Status`s

There maybe another (and easier) way of listing the virtual machine status`s if so please send it in.

vmware-cmd -l | sed '/^$/d' |  while read VMX ; do STATE=$(vmware-cmd  "${VMX}" getstate | awk ' { print $3 } ') ;  echo "${VMX}" = "${STATE}" ; done
    Blogger Comment
    Facebook Comment