An all-CLI approach to starting/stopping VMs in ESXi 5.1

You could do that without vSphere client, you knew that?!?

Provided that SSH is enabled on ESXi (link opens another window), log in to the root prompt the follow the steps below:

  1. first, verify that the host is/isn’t in Maintenance mode:
    # vim-cmd hostsvc/hostsummary | grep Maintenance
    inMaintenanceMode = false,
  1. obviously, if it is, leave Maintenance mode:
    # vim-cmd hostsvc/maintenance_mode_exit
    'vim.Task:haTask-ha-host-vim.HostSystem.exitMaintenanceMode-xxx'
  1. then, check which VMs are available (output edited):
    # vim-cmd vmsvc/getallvms
    Vmid  Name               File                      Guest OS     Version
    1    name_1  [storage_1] Debian 64 6.x/vmx1.vmx  LinuxGuest     vmx-08
    2    name_2  [storage_2] Windows XP 1/vmx2.vmx   winXPProGuest  vmx-07
    3    name_3  [storage_3] Windows XP 2/vmx3.vmx   winXPProGuest  vmx-08 
  1. VMs can be started as follows:
    # vim-cmd vmsvc/power.on 2
    Powering on VM:

The opposite process, i.e. to shutdown the VMware server, is:

  1. gracefully shutdown the VMs one-by-one
  2. enter Maintenance mode:
    # vim-cmd hostsvc/maintenance_mode_enter
    'vim.Task:haTask-ha-host-vim.HostSystem.enterMaintenanceMode-yyy'
  3. shutdown services:
    # shutdown.sh
  4. power-off the server:
    # poweroff

Yep, that's all you have to do, no need for vSphere client for the time being :)

Links:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1038043

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=9639912