Enter and Exit Maintenance Mode with ESXCLI

You place a host in maintenance mode to service it, for example, to install more memory. A host enters or leaves maintenance mode only as the result of a user request.
esxcli system maintenanceMode set
allows you to enable or disable maintenance mode.
When you run the
vicfg-hostops
vCLI command, you can specify one of the options listed in Connection Options for vCLI Host Management Commands in place of
<conn_options>
.
  1. To enter maintenance mode, run the following command.
    esxcli <conn_options> system maintenanceMode set --enable true
    After all virtual machines on the host have been suspended or migrated, the host enters maintenance mode.
    You cannot deploy or power on a virtual machine on hosts in maintenance mode.
  2. To exit maintenance mode, run the following command.
    esxcli <conn_options> system maintenanceMode set --enable false
    If you attempt to exit maintenance mode when the host is no longer in maintenance mode, an error informs you that maintenance mode is already disabled.