Indicate policy falure if script failes.

kuwaharg
New Contributor III

Is there a way to have the policy execution status be "failed" if the script within the policy fails a test?

I have a policy that runs a script. At the end of the script I test to see if it was successful. How do I pass its failure to the policy so that it indicates the scripts success or not? I played with exit values on the script, but the policy still states it successful no matter if it passed the test or not.

Thanks, Gretchen

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

@kuwaharg / Gretchen
the trick is to echo something like "error" or "failure" in the script when you detect the success or failure of the scripts results, which gets picked up by the policy. Anything echoed to stdout gets captured in the policy log. If it sees those words, it will note the policy as having failed. This should also be noted in a Self Service policy to the end user running it.

Note that Casper Suite version 9 changed this a little according to release notes, so I don't know if the above still works there, or if you'd need to do something else. But the above steps will work in version 8.x.

View solution in original post

2 REPLIES 2

mm2270
Legendary Contributor III

@kuwaharg / Gretchen
the trick is to echo something like "error" or "failure" in the script when you detect the success or failure of the scripts results, which gets picked up by the policy. Anything echoed to stdout gets captured in the policy log. If it sees those words, it will note the policy as having failed. This should also be noted in a Self Service policy to the end user running it.

Note that Casper Suite version 9 changed this a little according to release notes, so I don't know if the above still works there, or if you'd need to do something else. But the above steps will work in version 8.x.

kuwaharg
New Contributor III

Thanks for your help Mike! That works for my 8.x environment.