How to tracing script flow

Question:

I’m fairly new to Powershell and have written some pretty large scripts ie a script that calls others scripts which have functions nested in other functions. When I launch this script I sometimes get errors that I don’t know where they came from. Is there an easy way to see where this script terminated so I can troubleshoot the error?

Answer:

You can use Set-PsDebug to get PowerShell to output almost every line it runs:

Only downside is you’ll probably end up with a lot of output to wade through…

Source:

How to tracing script flow by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply