VMware Cloud Community
dwilli
Enthusiast
Enthusiast

Cannot shutdown VM with PowerCLI

I have a VM that will not shutdowna nd is hung up.  When I try to shut it down with the PowerCLI 5.0.1 i get an error that says:

Operation Shutdown Gueast VM failed for vmname for the follwoing reason: Another task is already in progress.

How can I identify the task and kill it so I can reboot the VM.

Reply
0 Kudos
5 Replies
hkpVCP
Contributor
Contributor

If it is a task running on the vcenter you could try this:

Get-Task | where {$_.ObjectID -eq (Get-VM VMname | select -ExpandProperty Id)} | where {$_.State -eq "Running"}

That will return all the running tasks on that VM.

You can take off the last pipe to get all the tasks for that VM no matter the state.

Probably not the answer you are looking for, but if it is hung you may not be able to use the shutdown guest option.  You may have to power off the VM.  You can use 'Stop-VM' for that.

dwilli
Enthusiast
Enthusiast

Thanks for the reply.  I tried the stop-vm and it cannot kill the VM either with the same error.

Reply
0 Kudos
redbaron51
Enthusiast
Enthusiast

try ssh into the host or using a vma and use the command: vmware-cmd /path to VM/ stop hard

let's us know how you get on

---------------------------------------------------------------------------------------------------------------------------------------- If you found the post useful please award correct/helpful points.
dwilli
Enthusiast
Enthusiast

That did not work, but I was bale to do the following to get the VM to shutdown, i used the type=hard and the VM shutdown right away.

Connect via SSH

  • Get a list of running virtual machines, identified by World ID, UUID, Display Name and path to the .vmx configuration file, using this command:

    esxcli vm process list


  • Power off one of the virtual machines from the list using this command:

    esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber

    Note: Three power-off methods are available. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.


Reply
0 Kudos
nava_thulasi39

Incase if you don't have VMA, still you can kill using esxtop from the KB article no 1014165

  1. On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support mode for Emergency Support (1003677).
  2. Run the esxtop utility using this command:

    esxtop


  3. Press c to switch to the CPU resource utilization screen.
  4. Press f to display the list of fields.
  5. Press c to add the column for the Leader World ID.
  6. Identify the target virtual machine by its Name and Leader World ID (LWID).
  7. Press k.
  8. At the World to kill prompt, type in the Leader World ID from step 6 and press enter.
  9. Wait 30 seconds and validate that the process is not longer listed.

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos