9.2. Debugging Your Code

Debugging is the black art of finding and eliminating errors in computer programs. Logic errors have long been referred to as bugs, and popular legend has it that the first bug was a real moth stuck between the contacts of a relay in the U.S. Navy's Harvard Mark II computer. The fix back then was simple; the bug was extracted using tweezers.

Most programming languages and environments ship with a fully featured debugger system, a means to execute a program step-by-step and to inspect the intermediate results of its execution. For better or for worse, PowerShell does not contain a script debugger, and we have to resort to other techniques to eliminate errors in our programs. Luckily, using some ingenious tricks, we can ...

Get Pro Windows PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.