title: How to show error in PowerShell step called from SQL Server 2008 R2 job?
body: <p>I've been looking around online, but haven't found very much.   As a matter of fact, the most info has been here on stackoverflow - <a href="https://stackoverflow.com/questions/3823661/show-failure-for-sql-2005-job-that-executes-powershell-script-through-cmd-prompt">Show failure for SQL 2005 Job that executes Powershell script through CMD prompt, IF PS script fails</a> but that's with SQL Server 2005, I'm hoping things have improved in 2008.</p>
  
  <p>Anyway, I want to be able to have the SQL Server Agent job FAIL if the the Powershell script fails.  In SQL Server I'm using a powershell step, with just this:</p>
  
  <pre><code>write-output "this is a test error"
  exit -1
  </code></pre>
  
  <p>I thought this would cause the SQL Server job to error, but it's not happening, it shows successful.  Is it necessary to use a cmdexec step, and then shell out to powershell, in order to be able to get errors when they occur?</p>
  
  <p>thanks,
  Sylvia</p>