2 Replies Latest reply on May 16, 2019 1:10 PM by hguthrie

    Disk Consolidation Script -- Issue retrieving status/error message

    hguthrie Lurker

      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.