Task Status has two states Success or Fail, the way this is mapped from the 4 states that the module can return is that only Fatal Errors result in Failed tasks. Since this module is used in both rules and tasks and in the rule case we do not want to unload we only return Fatal Errors if the problem is deemed to be unrecoverable, meaning the next time the module runs there is no chance it will complete successfully.
So the trick is to make the module return Fatal Error. This is difficult at best in RTM, however in SP1 there is a reasonable way to accomplish this. On the Module there is an ‘EventPolicy’ element, this element drives when the Script and Command Executor modules create events in the event log, but it also controls how those events are reported to the engine. Which means that you as an MP author have control over how errors are reported. This element is defined as:
The ‘Operator’ attribute indicates that you either want to create an event on ‘MatchesRegularExpression’ or ‘DoesNotMatchRegularExpression’ (defaults to matches), the ‘CaseSensitive’ attribute indicates if your expression is case sensitive (defaults to true or case sensitive), and the inner text of each element is a regular expression in Atl syntax (see
for more information).
So to put this all together, to make your task fail if for instance you hit a script error you could simply add the following XML to your script module configuration:
<!-- Report a Fatal Error -->
<!-- Report an Error if there is anything in StdErr
Cscript.exe writes out unhandled errors to StdErr so
Any text here indicates an unhandled error -->
Also keep in mind that the script modules already have defaults for these. And that overriding is done per field, so in other words if you only modify the Severity in the EventPolicy then it would simply override this field, the defaults for the StdOut, StdErr, and ExitCode would still apply. The defaults look like this for the WriteAction and Probe which produces ‘System.CommandOutput’: