Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Specifying PowerShell Error Actions

$
0
0

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: SilentlyContinueStopContinueInquire, or Ignore.

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.


Viewing all articles
Browse latest Browse all 3333

Trending Articles