Chapter 30. Error handling techniques
This chapter covers
- Error handling parameters and variables
You’ll inevitably write a script that contains a command that fails. Failure is often something you can anticipate: A computer isn’t online or reachable, a file can’t be found, access is denied, and other similar conditions are all ones that you expect from time to time. PowerShell enables you to catch those errors and handle them in your own way. For example, you might want to log a failed computer name to a file for retrying, or you might want to write an entry to the Windows event log when access is denied. Error handling is the process of identifying these conditions, catching the error, and doing something about ...