August 21st, 2014

PowerTip: Mini-Scripting Games 2014 Answer 4

Doctor Scripto
Scripter

Summary: Here is the answer to the fourth question in Mini-Scripting Games 2014.

Hey, Scripting Guy! Question You are attempting to use Try/Catch/Finally in your script. No matter what you try,
            the script never seems to catch it. What is the most likely cause of the problem?

Hey, Scripting Guy! Answer The most likely cause of the problem is that your Try statement does not generate a terminating error,
            and therefore, there is nothing for Catch to catch.

 One easy way to fix this is to change your $ErrorActionPreference variable from Continue to Stop.
 This will cause your non-terminating errors to actually terminate and send the control to the 
 Catch portion of your script.

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.