Update: Microsoft will be moving away from UserVoice sites on a product-by-product basis throughout the 2021 calendar year. We will leverage 1st party solutions for customer feedback. Learn more here.

Liam Fisher

My feedback

  1. 24 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    2 comments  ·  Automation » Debugging and troubleshooting  ·  Flag idea as inappropriate…  ·  Admin →
    under review  ·  Beth Cooper responded

    Can you provide more detail on what you mean by useful? Do you want to know where in the code the error occurred? Can you provide an example of what you find useful for debugging PS in the ISE?

    You may want to try using ErrorRecord.InvocationInfo for non-terminating errors since on non-terminating errors, we currently save this data in the Error stream.

    On terminating errors (exceptions), this data is currently lost. But we can investigate storing this information to present it for debugging. I would like to make sure that this is the info that you are looking for though, so please confirm.

    As a workaround for now, you could write a global try/catch block in the runbook (which will also catch exceptions thrown because of $ErrorActionPreference = ‘Stop’) and write $_.ErrorRecord.InvocationInfo to a stream.

    An error occurred while saving the comment
    Liam Fisher commented  · 

    Hi Beth, why is the invocation info not shown in the runbook error message? This is useful information and I constantly end up writing a horrible trap block that prints out the invocationinfo position and message on failure. I believe that is the information the OP was looking for.

Feedback and Knowledge Base