Menu Close

Power off VM by command(vim-cmd)

Next post: Power off VM using esxcli

  1. Log in as root to the ESX host where the impacted virtual machine located using an SSH client
  2. Get a list of all registered virtual machines, identified by their VMID and Display Name by running this command: #vim cmd vmsvc getallvms
  3. Take note of the impacted virtual machine ID VMID
  4. Get the current state of a virtual machine by running this command: #vim-cmd vmsvc power.getstate VMID
  5. Check if there hanging task on the impacted virtual machine that prevent the machine from powering on by running this command: #vim-cmd vmsvc/get.tasklist VMID #vim-cmd vimsvc/task_info <task id> #vim-cmd vimsvc/task_cancel <task id> Note: not all tasks are cancellable
  6. Shutdown the virtual machine using the VMID: #vim-cmd vmsvc/power.shutdown VMID
  7. If the virtual machine fails to shutdown: #vim-cmd vmsvc/power.off VMID

Leave a Reply

Your email address will not be published. Required fields are marked *