January 15, 2014 at 9:05 am
I have a powershell script that has 2 steps. The script is called by a SQL agent job. If a step fails, it is sending back the error to the job but wasn't actually failing the job. I found if I use "throw", it will fail the job. However if the 1st step fails, then it exits the script. I need it to continue on but still show a job failure regardless if step 2 fails or not. Is that possible?
January 15, 2014 at 12:22 pm
How about a try-catch around the first step. Set a variable indicating success or failure, then do step 2, and then throw that variable?
January 15, 2014 at 3:29 pm
Thanks for the idea. I didn't use try-catch since I used -errorvariable in my statement, so instead of calling the throw right after the error occurrs, I waited until the end and checked all errorvariables and called the throw then if they weren't NULL. That was simple. Thanks!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy