0

I have a PS script which connects to MS SQL and makes changes in the DB and if the SQL script fails, my ps script still continues with the next steps. So I wonder what is a good way to stop the script after it failed on SQL side? My Powershell didn't recognize the normal abortion from SQL, so is the another way?

1
  • 1
    Posting the code you're working with will help people help you. Commented Jan 9, 2014 at 13:45

3 Answers 3

1

If you find a way to check if your SQL script worked or not (if you don´t know how you should provide a little more info on what you are doing), you can use Break to stop your powershell script.

Sign up to request clarification or add additional context in comments.

Comments

1

Take a look at $ErrorActionPreference. You can set this at a script level to Stop.

Comments

1

This is basic error handling. See if this help:

http://www.microsoftvirtualacademy.com/Content/ViewContent.aspx?et=3447&m=3443&ct=18350#?fbid=8N34OvP1Y5K

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.