powershell capture call stack after an error is thrown

Posted by davidhayes on Stack Overflow See other posts from Stack Overflow or by davidhayes
Published on 2010-03-11T21:06:21Z Indexed on 2010/03/11 21:09 UTC
Read the original article Hit count: 242

Hi, 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)
Any ideas how to achieve this?
Dave

© Stack Overflow or respective owner

Related posts about powershell

Related posts about error-handling