Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell verbose output for chained exceptions

I'm new to powershell and troubleshooting an issue with one of our custom cmdlets. By default, all exceptions thrown within the cmdlet have minimum information, no stack trace and no info on chained exceptions. Is there a way to enable verbose output of exceptions?

like image 870
kateroh Avatar asked Dec 21 '22 14:12

kateroh


1 Answers

the $error collection contains a live list of all unhandled exceptions thrown in the current session. The last exception is at $error[0]. A good technique to do something like this to capture the error as soon as possible:

ps> invoke-something
error: ...
ps> $e = $error[0]

Explore $e with get-member.

like image 167
x0n Avatar answered Jan 14 '23 01:01

x0n