August 10th, 2012

PowerTip: Specifying PowerShell Error Actions

Doctor Scripto
Scripter

Summary: Specify Windows PowerShell error actions. Question: Which command when typed at the beginning of a script will cause Windows PowerShell to ignore errors and continue executing the code?

Answer: $erroractionpreference=SilentlyContinue Question: How can I ignore errors for a single command instead of for the entire script?

Answer: Use the ErrorAction parameter and specify one of the following values: SilentlyContinue, . Question: That is a lot of typing. Is there an easier way to specify the ErrorAction for a single command?

Answer: Yes. You can use the parameter alias EA and use a number value for the action. For example, 0 is SilentlyContinue, 1 is Stop, 2 is Continue, 3 is Inquire, or 4 is Ignore.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback