Introduction

    When we say that a script “handles” an error, this means it reacts to the error by doing something other than the default behavior. In many programming and scripting languages, the default behavior is simply to output an error message and immediately crash. In PowerShell, it will also output an error message, but will often continue executing code after the error occurred.

    How this book is organized

    Following this introduction, the book is broken up into four sections. The first two sections are written to assume that you know nothing about PowerShell error handling, and to provide a solid background on the topic. However, there’s nothing new in these sections that isn’t already covered by the PowerShell help files. If you’re already fairly familiar with the ErrorRecord object and the various parameters / variables / statements that are related to reporting and handling errors, you may want to skip straight to sections 3 and 4.

    These tests reveal a couple of tricky bugs, particularly involving the use of ErrorVariable.