17.8. Summary
Errors in Windows PowerShell are stored in the $Error variable. The default size is 256 errors. You can increase the size of $Error if desired.
Errors can be described as terminating errors and nonterminating errors. The distinction is not clear-cut.
The $ErrorActionPreference variable allows you to specify a global preference for PowerShell behavior when an error occurs.
The $Error View variable allows you to specify two views of error information.
Two of the common parameters are relevant to errors:
The -errorAction paramter overrides for an individual cmdlet the value in $ErrorActionPreference.
The -errorVariable parameter allows you to store error information in a variable other than $Error.
The write-error cmdlet allows you to create custom error messages.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access