23
Debugging
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. ...
Get Mastering PowerShell Scripting - Fifth Edition 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.