You can use the ESXi command line to start virtual machines. First issue the command
~ # vim-cmd vmsvc/getallvms
to show a list of all the registered virtual machines on an ESXi host, while
~ # vim-cmd vmsvc/getallvms | grep [VM name]
allows you to select a virtual machine by its name. If a virtual machine is not available on an ESXi host and you want to register a virtual machine you might want to use
~ # vim-cmd solo/registervm /vmfs/volumes/[VMFS volume name]/[VM directory name]/[VM vmx file]
To start the virtual machine from the command line, use the command:
~ # vim-cmd vmsvc/power.on 23
In this case ’23’ is the ID of the virtual machine, displayed by the getallvms command. Note that this ID is not static and will change after you for example move a VM to another ESXi host.
After registering a new virtual machine to a host through the command-line, there’s a chance the VM will not start and seems to be pausing forever. This has to do with a question ESXi is asking you; unfortunately you will not see this question by default. Cancel the power.on action (CTRL-C) and issue the following command to see the question and answer it:
~ # vim-cmd vmsvc/message 23 Virtual machine message _vmx1: msg.uuid.altered:This virtual machine might have been moved or copied. In order to configure certain management and networking features, VMware ESX needs to know if this virtual machine was moved or copied. If you don't know, answer "I copied it". 0. Cancel (Cancel) 1. I moved it (I moved it) 2. I copied it (I copied it) [default] ~ # vim-cmd vmsvc/message 23 _vmx1 1
The last command answers the question, the format is vim-cmd smvc/message VM-ID Question-ID answer.Give the appropriate answer depending on the situation.
After answering the message, your VM will continue the power.on action you’ve cancelled earlier (pretty cool :-)) .
To verify the powerstate of the VM:
~ # vim-cmd vmsvc/power.getstate 23 Retrieved runtime info Powered on
The VM is powered on now and will start to boot!
- VMware KB 1038043: Powering on a virtual machine from the command line when the host cannot be managed using vSphere Client
- VMware KB 1026835: Answering a virtual machine related question from the command line
- VMware KB 1006160: Registering or adding a virtual machine to the inventory on vCenter Server or on an ESX/ESXi host