Put ESX Into Maintenance Mode From the CLI

There are times when you will need to put a host into, or take a host out of maintenance mode and you wont otherwise have the remote access needed to make PowerCLI or other API methods work. For times like those, vimsh works wonders:

This little gem comes from xtravirt:

To enter Maintenance Mode, at the ESX console type:
vimsh -n -e /hostsvc/maintenance_mode_enter

To exit Maintenance Mode type:
vimsh -n -e /hostsvc/maintenance_mode_exit

To display whether the ESX Server is currently in maintenance mode or not type:

vimsh -n -e"hostsvc/hostsummary" | grep inMaintenanceMode