Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a SQL job whose step of 'PowerShell' type does 'exit 1' if encounters an error i.e.

$ErrorActionPreference='stop'; trap{"$_"; exit 1}

Problem is, SQL Server doesn't pay attention to that exit code, and reports "The step did not generate any output. Process Exit Code 0. The step succeeded."

Any idea how to successfully tell SQL Server from a PowerShell step that something went wrong?

Thanks in advance.

share|improve this question

1 Answer 1

throw "Failure" will work. See this MSDN forum post for additional information:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.