By default, PowerCLI cmdlets return an output only after completion of the requested tasks. If you want a cmdlet to return to the command line immediately, without waiting for the tasks to complete, you can specify the RunAsync parameter.

When you specify the RunAsync parameter, the cmdlet returns Task objects instead of its usual output.The Status property of a returned Task object contains a snapshot of the task’s initial state. This state is not updated automatically and has the values Error, Queued, Running, or Success. You can refresh a task state by retrieving the task object with the Get-Task cmdlet. If you want to observe the progress of a running task and wait for its completion before running other commands, use the Wait-Task cmdlet.

Note

In VMware vSphere PowerCLI, the RunAsync parameter affects only a cmdlet's invocation and does not control whether the initiated tasks run consecutively or in parallel. For example, the Remove-VM cmdlet might remove the specified virtual machines simultaneously or consecutively depending on the PowerCLI internal design. To make sure that tasks initiated by a cmdlet run consecutively, run the cmdlet in a loop, each time applying it to a single object.

Remove-VM $vmList

The command returns no output when all virtual machines stored in the $vmList variable are removed, irrespective of whether they are removed simultaneously.

Remove-VM $vmList -RunAsync

The command returns immediately an output that consists of one or more Task objects.