Automation

 View Only
  • 1.  Cannot shutdown VM with PowerCLI

    Posted Feb 21, 2012 02:39 PM

    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.



  • 2.  RE: Cannot shutdown VM with PowerCLI

    Posted Feb 21, 2012 03:32 PM

    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.



  • 3.  RE: Cannot shutdown VM with PowerCLI

    Posted Feb 21, 2012 04:01 PM

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



  • 4.  RE: Cannot shutdown VM with PowerCLI

    Posted Feb 21, 2012 05:29 PM

    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



  • 5.  RE: Cannot shutdown VM with PowerCLI

    Posted Feb 21, 2012 05:45 PM

    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.




  • 6.  RE: Cannot shutdown VM with PowerCLI

    Posted Feb 21, 2012 05:46 PM

    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.