title: Powershell ScheduledTask to report error
body: <p>So if we use the following to create a scheduled task in powershell</p>
  
  <pre><code>Register-ScheduledJob -Name TestJob3 -ScriptBlock { 
      throw "This is an ugly error that should be visible" 
  } -Credential $cred
  </code></pre>
  
  <p>...and then run this task.  </p>
  
  <p>The task scheduler reports success.</p>
  
  <p>So we can slightly improve on this by changing the scriptblock to something like the following</p>
  
  <pre><code>try{
      throw "This is an ugly error that should be visible" 
  } catch {
      Exit -1
  }
  </code></pre>
  
  <p>Now if you look very carefully you can see that the task scheduler is reporting a last run result of something other than 0 (0xFFFFFFF).
  However all we have in the history tab is bunch of infomation logging saying that the task and action have completed.</p>
  
  <p>What I would really like is to get some big loud exception level logging in the history view preferably with the nice descriptive error that has been thrown.</p>
  
  <p>Anyone know how this can be achieved?</p>