Extension Attribute works local but not via Jamf Pro

JevermannNG
Contributor II

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 12

sdagley
Esteemed Contributor II

@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
Honored Contributor II

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
Esteemed Contributor II

@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
Esteemed Contributor II

@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:

Screenshot 2023-02-02 at 09.08.41.png

 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:

Screenshot 2023-02-02 at 09.12.39.png

Screenshot 2023-02-02 at 09.13.02.png

sdagley
Esteemed Contributor II

@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!

Screenshot 2023-02-02 at 14.16.49.png

sdagley
Esteemed Contributor II

@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>"