So if we use the following to create a scheduled task in powershell
Register-ScheduledJob -Name TestJob3 -ScriptBlock {
throw "This is an ugly error that should be visible"
} -Credential $cred
...and then run this task.
The task scheduler reports success.
So we can slightly improve on this by changing the scriptblock to something like the following
try{
throw "This is an ugly error that should be visible"
} catch {
Exit -1
}
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.
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.
Anyone know how this can be achieved?