I want to do something like this…
try
{
# Something in this function throws an exception
Backup-Server ...
}catch
{
# Capture stack trace of where the error was thrown from
Log-Error $error
}
Ideally I’d like to capture arguments to the function and line numbers etc. (like you see in get-pscallstack)
EDIT: To clarify, it’s the powershell stack trace I want not the .NET one
Any ideas how to achieve this?
Dave
The last error is sitting in:
Lots of good info in there for you to chase down including exception stack traces. This is a handly little script (Resolve-ErrorRecord that ships with PSCX) that shows lots of good info about the last error: