First off, this is a follow-up to a post from a little over a month ago. The script has been expanded significantly since then and has given me a chance to explore using -WhatIf and other more sophisticated features.
Here's a link to the current script (with a few variables redacted).
If the disk consolidation task encounters an error, I'm having trouble retrieving an error message. The Invoke-DiskConsolidation function creates the ConsolidateVMDisks_Task() on line 143, and I keep track of the Task ID and VM name in a HashTable so that I can retrieve the task's State (Success, Error, or Running). I can't figure out how to retrieve a potential error message.
From the vSphere GUI, I can see the tasks created by the script and their associated status/error message of "Unable to access file since it is locked", but I can't figure out how to retrieve this message using PowerCLI.
When you have the failing Task in $task, did you already check $task.ExtensionData.Info.Error?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
When you have the failing Task in $task, did you already check $task.ExtensionData.Info.Error?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
That's it! Thanks so much.