Runing such script:
1: function foo() 2: { 3: bar 4: } 5: 6: function bar() 7: { 8: throw \"test\" 9: } 10: 11: foo
I see
Stumbled upon this looking for a built in solution. I am going with simple solution. Just add trace block before using any powershell. This will ensure a call stack is shown. Down side of this is the stack will be displayed before the error message.
Trace { $_.ScriptStackTrace }