Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

Fail sql job if error is encountered in powershell script

$
0
0
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?

Viewing all articles
Browse latest Browse all 467

Trending Articles