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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.