Debugging and Troubleshooting
Debugging is the art of discovering, isolating, and fixing bugs in code. The complexity of debugging increases with the complexity of the code.
To a degree, the need to debug complex scripts can be reduced by adopting certain development strategies:
- Scripts should be broken down into discreet units by using functions
- Each unit of code should strive to excel at one thing only
- Each unit of code should strive to be as short as it can reasonably be without sacrificing clarity
- Tests should be developed to ensure that each unit of code acts as it should
- Use commands such as
Write-Verbose
orWrite-Debug
to write identifiable messages, perhaps including values of variables
Debugging is an inevitable part of the development process. Fortunately, the debugger itself is not difficult to use.
This chapter explores the following topics:
- Common problems
- Debugging in the console
- Debugging...