9.1. Handling Errors

Errors in PowerShell can be of two kinds: terminating and nonterminating. The first kind of is similar to the exception concept found in many programming languages. Those are errors that are triggered because the command interpreter has encountered an exceptional situation and cannot continue. Once we raise such an error, all further execution stops. Typical terminating errors are raised by script syntax errors, trying to call nonexistent commands, or something of a similar severity. User-raised errors resulting from the throw statement, which we will look into later in this chapter, are also terminating errors.

Nonterminating errors are less severe. Those are usually errors indicating that the current command cannot be ...

Get Pro Windows PowerShell 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.