Automation

 View Only
  • 1.  Check if any tasks are running against a VM in vCenter?

    Posted Jun 27, 2016 07:27 PM

    I need to write some powercli to see if a VM is being snapped, vmotioned or possibly other operation.  How can I check if a task is running on the specified VM in vCenter?

    I know how to get the running tasks in vCenter:

    $task = Get-Task -Status Running

    But how do I determine what the target is of the tasks?



  • 2.  RE: Check if any tasks are running against a VM in vCenter?
    Best Answer

    Posted Jun 28, 2016 04:42 AM

    Try something like this

    Get-Task | where{$_.ObjectId -match '^VirtualMachine'} |

    Select StartTime,State,@{N='VM';E={Get-View -Id $_.ObjectId -Property Name | select -ExpandProperty Name}},Description



  • 3.  RE: Check if any tasks are running against a VM in vCenter?

    Posted Jul 26, 2019 04:35 PM

    This is the best. Was scrounging the internet just for this answer as I'd struck the same question a few days ago and lo and behold -- found it! Spent several hours trying to do exactly what was provided in this thread and absolutely need to practice/learn so much more.

    Thank you again!!



  • 4.  RE: Check if any tasks are running against a VM in vCenter?

    Posted Jul 13, 2021 04:43 AM

    can we filter out only running task and select one VM only 



  • 5.  RE: Check if any tasks are running against a VM in vCenter?

    Posted Jul 13, 2021 07:14 AM

    Yes, with a Where-clause