Hi All -
I'm trying to use the task object that's returned when you use the RunAsync command.
$mytask = Import-VApp -Source myfile.ova -VMHost (Get-VMHost | Select-Object -First 1) -Location (Get-Cluster $clustername) -RunAsync
$mytask.Id returns f9aef898-57e1-45c4-b292-c5b7e37ad3b5 instead of something like Task-task132.
How can I use the data here to query a task with Get-Task -Id?
The only other way I can think of doing this is starting the task, then using Get-Task filtering on "Deploy OVF template" to pull the ID, which is kinda hokey. I thought I would be able to get it directly from the task. :smileyconfused:
Thanks in advance.
The Id property doesn't show a MoRef anymore since quite some PowerCLI builds.
If you need to wait for the task to complete, you can also use the Wait-Task cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the reply LucD. I played around with Wait-Task, but I was looking for a bit more flexibility on checking for task status.
What I wound up doing is starting my task, then using Get-Task, filtering out what should be the task I just started, then using Select-Object -Last 1 to get the most recent one. Seems to be working so far.
Ron