Shutdown or startup ESXi Virtual Machines from the Host Command Line

Shutdown or startup ESXi Virtual Machines from the Host Command Line

Sometimes you need to be able to shutdown or startup virtual machines when all you have is a command-line prompt on the server itself. So how do we achieve this in the easiest way possible?

Especially since you have no remote access to the server (otherwise, you’ll have used the inbuilt ESXi VMware tools remotely), or via the VCSA (vCentre Server Appliance, which would be the preferred way of managing the server).

Enabling ESXi Shell

Firstly we need to be able to get to the local ESXi command line on the server itself. This happens in two parts, enabling the ESXi Shell, and then accessing the ESXi shell itself.

Enabling the ESXi Console

Enabling the ESXi shell can be done from the server itself. At the console, press a key to wake up the host, then enter the credentials necessary. Select Troubleshooting Options from the menu, and Enable ESXi Shell, then press <Enter>.

If this is already enabled, the option will be Disable ESXi Shell.

Accessing the ESXi Console

Pressing Alt-F1 switches from the familiar VMware status screen to a login prompt. Enter valid username and credentials, and you’ll end up at the ESXi Shell prompt, from where you can drive the server.

Listing Available Virtual Machines

We need first of all to determine the Virtual Machine ID for the guests we want to power off or on. The command below provides the name of the guest, as well as the VMID which we need for the later commands.

vim-cmd /vmsvc/getallvms

Checking the current Power State

We may need to check the current state of the power for the virtual machine after we’ve identified it. This means we can then determine if it’s running appropriately, or needs to be altered.

vim-cmd /vmsvc/power.getstate <VMID>

Now you can determine if you need to power-on or power off your guest VM.

Power Off your Guest VM

vim-cmd /vmsvc/power.off <VMID>

Power On your Guest VM

vim-cmd /vmsvc/power.on <VMID>
John Dixon

John Dixon is the Principal Consultant of thirteen-ten nanometre networks Ltd, based in Wiltshire, United Kingdom. He has a wide range of experience, (including, but not limited to) operating, designing and optimizing systems and networks for customers from global to domestic in scale. He has worked with many international brands to implement both data centres and wide-area networks across a range of industries. He is currently supporting a major SD-WAN vendor on the implementation of an environment supporting a major global fast-food chain.

Comments are closed.