SQL Server: How to report error from a job's step of PowerShell type

Posted by Ariel on Server Fault See other posts from Server Fault or by Ariel
Published on 2010-08-20T20:47:36Z Indexed on 2014/05/31 9:33 UTC
Read the original article Hit count: 206

Filed under:
|

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.

© Server Fault or respective owner

Related posts about powershell

Related posts about sql