Skip to main content
Question

Extension Attribute works local but not via Jamf Pro

  • January 31, 2023
  • 12 replies
  • 34 views

JevermannNG
Forum|alt.badge.img+8

Hey,

I want to collect the information from our Mac Clients, if the automated software update check is enabled. The BASH Script for this action works locally on my Mac and I get the correct information when used in Jamf Pro as an EA. But all other Mac clients do not report anything back ... the Software Update is managed by a configuration profile, any ideas? Thank you!

 

#!/bin/bash ########################################### # Check Status of AutomaticCheckEnabled # ########################################### AutomaticCheckEnabled=`/usr/bin/defaults read /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled` LastDateCheck=`/usr/bin/defaults read /Library/Preferences/com.apple.SoftwareUpdate LastSuccessfulDate` if [ $AutomaticCheckEnabled -eq 1 ]; then result="Yes" elif [ $AutomaticCheckEnabled -eq 0 ]; then result="No" else result="Unknown" fi echo "<result>$result - $LastDateCheck</result>"

 

 

12 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3567 replies
  • January 31, 2023

@JevermannNG Try this:

#!/bin/bash ########################################### # Check Status of AutomaticCheckEnabled # ########################################### AutomaticCheckEnabled=$(/usr/bin/defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled) LastDateCheck=$(/usr/bin/defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist LastSuccessfulDate) if [ $AutomaticCheckEnabled -eq 1 ]; then result="Yes" elif [ $AutomaticCheckEnabled -eq 0 ]; then result="No" else result="Unknown" fi echo "<result>$result - $LastDateCheck</result>"

JevermannNG
Forum|alt.badge.img+8
  • Author
  • Valued Contributor
  • 136 replies
  • January 31, 2023

@JevermannNG Try this:

#!/bin/bash ########################################### # Check Status of AutomaticCheckEnabled # ########################################### AutomaticCheckEnabled=$(/usr/bin/defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled) LastDateCheck=$(/usr/bin/defaults read /Library/Preferences/com.apple.SoftwareUpdate.plist LastSuccessfulDate) if [ $AutomaticCheckEnabled -eq 1 ]; then result="Yes" elif [ $AutomaticCheckEnabled -eq 0 ]; then result="No" else result="Unknown" fi echo "<result>$result - $LastDateCheck</result>"

@sdagley Thank you for the swift response, same result. Can I use the defaults command when settings are provided with a configuration profile?


AJPinto
Forum|alt.badge.img+26
  • Legendary Contributor
  • 2802 replies
  • January 31, 2023

@sdagley Thank you for the swift response, same result. Can I use the defaults command when settings are provided with a configuration profile?


Yes, you may need to put the full path to the plist though. 


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3567 replies
  • January 31, 2023

@sdagley Thank you for the swift response, same result. Can I use the defaults command when settings are provided with a configuration profile?


@JevermannNG I don't understand how the prefs file wouldn't exist if you've verified the profile with the settings is installed, but this version of the EA will tell you if it isn't:

#!/bin/bash ########################################### # Check Status of AutomaticCheckEnabled # ########################################### PrefsFilePath="/Library/Preferences/com.apple.SoftwareUpdate.plist" result="Prefs file not found" if [ -e "$PrefsFilePath" ]; then AutomaticCheckEnabled=$(/usr/bin/defaults read "$PrefsFilePath" AutomaticCheckEnabled) LastDateCheck=$(/usr/bin/defaults read "$PrefsFilePath" LastSuccessfulDate) if [ $AutomaticCheckEnabled -eq 1 ]; then acEnabled="Yes" elif [ $AutomaticCheckEnabled -eq 0 ]; then acEnabled="No" else acEnabled="Unknown" fi result="$acEnabled - $LastDateCheck" fi echo "<result>$result</result>"

JevermannNG
Forum|alt.badge.img+8
  • Author
  • Valued Contributor
  • 136 replies
  • February 1, 2023

@JevermannNG I don't understand how the prefs file wouldn't exist if you've verified the profile with the settings is installed, but this version of the EA will tell you if it isn't:

#!/bin/bash ########################################### # Check Status of AutomaticCheckEnabled # ########################################### PrefsFilePath="/Library/Preferences/com.apple.SoftwareUpdate.plist" result="Prefs file not found" if [ -e "$PrefsFilePath" ]; then AutomaticCheckEnabled=$(/usr/bin/defaults read "$PrefsFilePath" AutomaticCheckEnabled) LastDateCheck=$(/usr/bin/defaults read "$PrefsFilePath" LastSuccessfulDate) if [ $AutomaticCheckEnabled -eq 1 ]; then acEnabled="Yes" elif [ $AutomaticCheckEnabled -eq 0 ]; then acEnabled="No" else acEnabled="Unknown" fi result="$acEnabled - $LastDateCheck" fi echo "<result>$result</result>"

Hi @sdagley thank you for the great input. Unfortunately is the result "Unknown" even with a "LastDateCheck" from today. Is there any other way to check if the check mark is set?


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3567 replies
  • February 1, 2023

Hi @sdagley thank you for the great input. Unfortunately is the result "Unknown" even with a "LastDateCheck" from today. Is there any other way to check if the check mark is set?


@JevermannNG That is really weird. What is the result if you run the following command on one of the Macs reporting Unknown (run it via a Policy using the Execute Command option in the Files and Processes payload)?

/usr/bin/defaults read "/Library/Preferences/com.apple.SoftwareUpdate.plist"

 


JevermannNG
Forum|alt.badge.img+8
  • Author
  • Valued Contributor
  • 136 replies
  • February 2, 2023

@JevermannNG That is really weird. What is the result if you run the following command on one of the Macs reporting Unknown (run it via a Policy using the Execute Command option in the Files and Processes payload)?

/usr/bin/defaults read "/Library/Preferences/com.apple.SoftwareUpdate.plist"

 


@sdagleythat works and the result looks like this:

 Changing the EA to a Policy with Script option works. I get the correct output on a Mac with the Configuration Profile and on a Mac without the Profile:


JevermannNG
Forum|alt.badge.img+8
  • Author
  • Valued Contributor
  • 136 replies
  • February 2, 2023

Yes, you may need to put the full path to the plist though. 


@AJPintothank you for the hint, after fixing the path, it still does not return the expected result.


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3567 replies
  • February 2, 2023

@sdagleythat works and the result looks like this:

 Changing the EA to a Policy with Script option works. I get the correct output on a Mac with the Configuration Profile and on a Mac without the Profile:


@JevermannNG So we know the prefs info is available but not why the script isn't returning the right info when run as an EA. Can you post an image of your EA configuration screen for it?


JevermannNG
Forum|alt.badge.img+8
  • Author
  • Valued Contributor
  • 136 replies
  • February 2, 2023

@JevermannNG So we know the prefs info is available but not why the script isn't returning the right info when run as an EA. Can you post an image of your EA configuration screen for it?


Hi @sdagley  here it comes and thanks for the support!


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3567 replies
  • February 2, 2023

Hi @sdagley  here it comes and thanks for the support!


@JevermannNG Nothing looks odd there. Do you have any other EAs running? I'm wondering if you might have another EA that's somehow preventing completion of data collection. Could you try adding an EA to run the following script just to see if it returns anything:

#!/bin/sh result=$(/bin/ls -lah /var/tmp/kernel_panics) echo "<result>$result</result>"

JevermannNG
Forum|alt.badge.img+8
  • Author
  • Valued Contributor
  • 136 replies
  • February 3, 2023

@JevermannNG Nothing looks odd there. Do you have any other EAs running? I'm wondering if you might have another EA that's somehow preventing completion of data collection. Could you try adding an EA to run the following script just to see if it returns anything:

#!/bin/sh result=$(/bin/ls -lah /var/tmp/kernel_panics) echo "<result>$result</result>"

@sdagley  Yes, other EAs work fine. In this EA is only the first value "" ignored, the value for e,g, "LastSuccessfulDate" is collected as expected.

I have a similar issue with the following plist file: com.apple.screensaver.plist

The following script does not report anything back, maybe the same issue?

#!/bin/bash ########################################### # Check Status of ScreenSaver Settings # ########################################### idleTime=`/usr/bin/defaults -currentHost read com.apple.screensaver.plist idleTime` echo "<result>$idleTime</result>"