Hi,
I'm currently working on an Agent Task and we already had the experience that people think that the Task was successful because it stands it in the console which is only partially true as: Yes, the script ran, but not the way we wanted it to run.
So, I was wondering how we could control that.
I will try it now with throwing an exit code but I wanted to get some input in case anyone else worked out something already.
EDIT:
Tried it now with throw and exit 34. Both don't do the job.
Hi, the script works just fine, that's not the problem. Thing is: We configure and discover our checks from the registry, and therefore we want to provide a task in the console that deploys registry keys and values. Works just fine. However, in case some check already exists I want to return an error, so people don't think the check has been deployed successfully.
Of course it stands it in the output that the check already exists but people see a green icon and think it worked just fine.
if memory serves, the success of a task is determined by the numeric response code returned, which I believe can be 0, -1 or 2 for success, fail and timeout. I believe I have these in a document and will look them up for you. Also in this situation in the past, we've actually logged an event right from the script to and raised an alert from that to tip the user off. Truth be told, if they can't see the notice you present in task output, raising an alert is probably the most notable way to say "Hey buddy, your task failed!".
Hmm that's weird. I run a Powershell Write Action there and when I exit with some exit code it shows it as successful. When I throw an error it exits with code 1 which should be considered as an error as well. Will try exiting with -1 now.
EDIT: Doesn't work either ;)