Power and maintenance operations in ESXi 5.1 with esxcli
ESXi 5.1 comes with many improvements and one of them is new namespaces and commands in esxcli.
Those new commands enable a system administrator to perform a shutdown, a reboot or a maintenance operation in a host.
Under the system namespace the new commands are the equivalents of the classic vicfg/esxcfg-hostops which until now was the only way to perform such kind of operations with vCLI and are also accesible locally on ESXi Shell.
Maintenance mode operations
Getting the basic usage of the command is as simple as always. You can perform two operations.
- Get the state of the host
- Put the the host in or out of Maintenance Mode
~ # esxcli system maintenanceMode
Usage: esxcli system maintenanceMode {cmd} [cmd options]
Available Commands:
get Get the maintenance mode state of the system.
set Enable or disable the maintenance mode of the system.
~ #
- Get the state of the host
~ # esxcli system maintenanceMode get Disabled ~ #
- Put the host in Maintenance Mode
~ # esxcli system maintenanceMode set -e true -t 0 ~ # ~ # esxcli system maintenanceMode get Enabled ~ #
Power operations
With the shutdown command the host can be either rebooted or shutdown. If the ESXi server is not in Maintenance Mode mode the operation will not be allowed.
~ # esxcli system shutdown
Usage: esxcli system shutdown {cmd} [cmd options]
Available Commands:
poweroff Power off the system. The host must be in maintenance mode.
reboot Reboot the system. The host must be in maintenance mode.
~ #
For both task the delay and reason parameter must be provided.
~ # esxcli system shutdown poweroff Error: Missing required parameter -r|--reason Usage: esxcli system shutdown poweroff [cmd options] Description: poweroff Power off the system. The host must be in maintenance mode. Cmd options: -d|--delay=<long> Delay interval in seconds -r|--reason=<str> Reason for performing the operation (required) ~ #
- Power off the host
~ # esxcli system shutdown poweroff --delay=10 --reason=”Hardware maintenance”
- Reboot the host
~ # esxcli system shutdown reboot -d 10 –r “Patches applied”
Juanma.


Thanks for your post. I’ve found that when using the following command:
‘esxcli system shutdown poweroff -d 10 -r test’
results in the host becoming unresponsive to WOL requests, but powering off via the vSphere client will allow a WOL packet to boot the machine.
Any ideas on how to get round this? I would like to be able to script the powering down of the VMs and the Host and still allow a remote boot via WOL.
Cheers,
Thank for the article. One thing that I am looking for is if one can use esxcli to stop / start the tsm-ssh service. I have yet to find anything.