PowerCLI – Get All VM Details from get-task

I’ve been working on a project that uses the -runasync parameter on the move-vm cmdlet. The obvious problem with running jobs asynchronously is that you lose the ability to determine the status of whatever task as soon as you submit it.

I ran into a challenge on this project where I needed to validate some details from the job that was submitted asynchronously. It was more difficult and annoying than I thought it would be, but I managed to get a function together that can get a bunch of information.

The script assumes a pre-existing connection to vCenter and accepts the parameters below.

  1. Status_to_check – with a default value of “Initiate vMotion Receive operation”
  2. vCenter – the FQDN of the vCenter server. I added this in case you are connected to multiple vCenter servers.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright VirtJunkie.com © 2020