There are a number of scenarios where you want to fail your runbook
and make sure that the runbook status is “failed”
this could, for instance be
- Triggering runbook from service manager, or other external system which checks the result
- Triggering from PowerShell
- If you want to use the statistics properly in orchestrator.
There is one rule that decides if the runbook status is success,warning or failed.
Success = All Activities is success full
Warning = One or more activities has failed or warning
Failed = Last activity that executes has status failed.
The challenge is that many “failures” in runbooks, are logical errors, which the runbook does not know is an error
Examples:
- Searching for Service Request. Nothing found
- Runbook see it as success, since the search was made
- but we think it is a failure because we did not find what we needed
- Proper logging is implemented
- the last activity will be the logging activity, which is successful = runbook status: Success.
- to make it fail, we cant to insert an error after the logging activity.
How to do it:
- Add a Run .Net Script activity to the work space
- Use the following script to output the error:
throw @" My error message Runbook Name: My runbook "@
This means you runbook might look similar to this:
The above pictures shows an example of a Service Manager runbook, that i used in my session som NIC 2014.
Get the slides and runbook here
Hello !
Thank you very much for this post.
I would like to know if it’s possible to force a success status of the runbook ?
It’s usefull when I loop, and that the Runbook see it as warning while it’s a normal case.
Thank you in advance.
Regards.
Hello Matthias
You are welcome.
unfortunately i don’t think it is possible to force a success.
what you can do is to put the part that has the loop in its runbook and use invoke runbook to trigger it.
this way you have more control of the result.
Hello!
Thank you for your answer.
I hope that Microsoft will impelment this lack in a future version.
Regards.
Thanks! This is useful.
But a couple of questions: I use run program activity a lot in my runbooks as the last activity, and it is using command execution, with a path of .bat file, but the problem for run program activity will always return success. so it is hard to get a correct status. What is the best way to hand this?
thanks.