Skip to main content
Question

Extension attribute Script

  • Mar 3, 2025 7:46 PM UTC
  • 6 replies
  • 268 views

Forum|alt.badge.img+2

I am trying to setup an extension attribute to verify if MS defender is enabled on devices in our environment. When I save the EA I only get a response from 1 device but I need responses from all of my devices. Any advice would be appreciated! Thanks

 

#!/bin/sh echo "<result>`mdatp health | grep real_time_protection_enabled| awk '{print $3}'`</result>"

 

 

6 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • Mar 3, 2025 7:59 PM UTC

@nhenderson You should use the full path to the mdatp binary, and don't assume it's installed so you can report an error it if isn't. Something like this:

 

#!/bin/sh mdatpPath="/Path/To/mdatp" result="Not Installed" if [ -e "$mdatpPath" ]; then result=$("$mdatpPath" health | grep real_time_protection_enabled | awk '{print $3}') fi echo "<result>$result</result>"

 

(You were also missing a space preceding the pipe between your grep and awk statements) 


Forum|alt.badge.img+2
  • Author
  • New Contributor
  • Mar 3, 2025 8:14 PM UTC

@nhenderson You should use the full path to the mdatp binary, and don't assume it's installed so you can report an error it if isn't. Something like this:

 

#!/bin/sh mdatpPath="/Path/To/mdatp" result="Not Installed" if [ -e "$mdatpPath" ]; then result=$("$mdatpPath" health | grep real_time_protection_enabled | awk '{print $3}') fi echo "<result>$result</result>"

 

(You were also missing a space preceding the pipe between your grep and awk statements) 


I appreciate the quick response! I have made the changes and I will see if that works.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • Mar 6, 2025 7:28 PM UTC

I appreciate the quick response! I have made the changes and I will see if that works.


Keep in mind that devices will only show updated information for a new Extension Attribute once they submit new inventory back to your Jamf Pro console. Just wanted to mention that because a lot of people get confused at first on this. It's not going to update on all Macs immediately after it's created.


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • Mar 6, 2025 8:22 PM UTC

Keep in mind that devices will only show updated information for a new Extension Attribute once they submit new inventory back to your Jamf Pro console. Just wanted to mention that because a lot of people get confused at first on this. It's not going to update on all Macs immediately after it's created.


I can't believe nobody has created a FR to trigger a recon policy on all Macs when an EA is created/updated. :-)


MacJunior
Forum|alt.badge.img+9
  • Valued Contributor
  • Feb 9, 2026 12:32 PM UTC

​@nhenderson did you get manage to get it to work? 


pete_c
Forum|alt.badge.img+16
  • Honored Contributor
  • Feb 9, 2026 4:25 PM UTC

MS has some excellent EAs for this in their repo: 
https://github.com/microsoft/mdatp-xplat/tree/master/macos/jamf/ea