Script Help for Extension Attribute

SeanRussell
New Contributor II

Hello all, we are creating a script to report back if a system is compliant or non-compliant with out PIVM requirement. See below for the script I have so far. It works great in terminal, and returns either compliant or noncompliant as expected, but for some reason won't show anything as an EA script even after many recons. Am I not grasping something critical about what an EA does here? Thanks for any help, you guys rock!

See next post for script

9 REPLIES 9

SeanRussell
New Contributor II

wow copy and paste fail...

SeanRussell
New Contributor II

See attached screenshot9e36ccb89d9a4fd0b7e85eb90740d8ce

danny_hanes
Contributor

You need to put a result in your echo. You need that in order for it to show up in your EA

#!/bin/sh

Check="Compliant"

echo "<result>$Check</result>"

bpavlov
Honored Contributor

@SeanRussell To get scripts on JAMF Nation to appear in code format simply highlight your code and click on the >_ button. Alternatively you can simply add 3 backticks as as additional line in the top AND bottom of the script code like so:

```
My code
```

SeanRussell
New Contributor II

Thanks, I guess I don't understand the Check/Result thing fully. I've tried adding a few things to the script but I'm coming up empty. Will keep giving a shot. Thanks again!

mpermann
Valued Contributor II

@SeanRussell line 28 needs changed to echo "<result>NonCompliant</result>" and line 31 needs changed to echo "<result>Compliant</result>" for the EA to display properly. Hopefully that will help.

mm2270
Legendary Contributor III

One other small thing. For the purposes of an EA, at least one that isn't an "action" EA, I don't see the reason to put in an exit 1 in the case of a failed check, since you will never see that. The EA is simply uploading a result that you'll be able to track in your JSS whenever inventory is collected. I would leave out the exit lines altogether, or just make them both exit 0. Not that the exit 1 will cause any harm. It's just isn't doing anything for you in this case.

PeterClarke
Contributor II

Hi, In general you are correct - for reporting there is no need to throw an error.

However in this case there may be some point in "deliberately" throwing an error when "non-compliant"
- because it should show up in any logs as an error (that the thing is non-complient)
So in this case it's being used to convey extra information, beyond that, that the EA itself is showing..

i.e. the 'error' - that the thing was non-compliant - will also specifically appear in logs, showing as an 'error state'
That, I think, is what the author intended.

SeanRussell
New Contributor II

Thanks for everything everyone! That worked great~!