Chapter 11. A template for handling and reporting errors

Will Steele

Writing programs that work when everything goes as expected is a good start. Making your programs behave properly when encountering unexpected conditions is where it really gets challenging.

Marijn HaverbekeEloquent JavaScript: A Modern Introduction to Programming

Efficient, predictable error handling has been at the core of PowerShell’s design since its earliest days and has allowed scripters to design robust automation solutions with minimal effort. In small scripts a balanced combination of common parameters, the use of Write-Error, or perhaps Write-Warning, and some well-placed if/then statements generally prove to be enough for most scripter’s daily automation problems. ...

Get PowerShell Deep Dives now with O’Reilly online learning.

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