Debugging scripts

How do I get PowerShell to spit out what happens in each line of a script without having to type each variable every line?

IMO It’s relatively simple in ISE.

Refer

http://technet.microsoft.com/en-gb/library/dd819480.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/22/use-the-powershell-debugger-to-troubleshoot-scripts.aspx
http://blogs.msdn.com/b/powershell/archive/2009/01/19/debugging-powershell-script-using-the-ise-editor.aspx

ISESteroids has a “Variable Monitor” feature that sounds like what you’re looking for. The module isn’t free, but I’ve been very happy with the investment since I write PowerShell code for a living. It has a huge set of features to turn the ISE into a much more professional development environment.

Thanks guys. GJ I’ve seen all the links before but somehow I missed the functionality of ISE where it shows you the value when you hover your mouse over a variable. I’m just a beginner so ISESteroides would probably be an overkill at this stage but thanks for mentioning it.

I dunno, I think 'Steroids would make being a beginner somewhat easier.

Just add Write-Debug “$variablename” to each relevant part of your script and run the script with the -Debug switch. You’ll get debug output for each phase!