Can I get detailed exception stacktrace in PowerShell? – Stack Overflow

There is a function up on the PowerShell Team blog called Resolve-Error which will get you all kinds of detailsNote that $error is an array of all the errors you have encountered in your PSSession. This function will give you details on the last error you encountered.

function Resolve-Error ($ErrorRecord=$Error[0])
{
$ErrorRecord | Format-List * -Force
$ErrorRecord.InvocationInfo |Format-List *
$Exception = $ErrorRecord.Exception
for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException))
{ "$i" * 80
$Exception |Format-List * -Force
}
}

Source: Can I get detailed exception stacktrace in PowerShell? – Stack Overflow

Leave a Reply

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