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

PowerTip: Mini-Scripting Games 2014 Answer 4

$
0
0

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.


Viewing all articles
Browse latest Browse all 3333

Trending Articles