I am new to PowerShell and fix the problem with one of our custom cmdlets. By default, all exceptions included in the cmdlet have minimal information, no stack trace, and no information about encoded exceptions. Is there any way to enable verbose exception output?
Here's a neat feature that I stole from someone on the network. I have this in my profile and will gladly distribute it further:
#Get detailed information on an error 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 } }
$error , . - $error [0]. - , :
ps> invoke-something error: ... ps> $e = $error[0]
$e get-member.
I used this technique to get nested error objects:
$error[0]|format-list -force