Posted on 01-31-2023 07:14 AM
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>"
Posted on 01-31-2023 07:57 AM
@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>"
Posted on 01-31-2023 09:43 AM
@sdagley Thank you for the swift response, same result. Can I use the defaults command when settings are provided with a configuration profile?
Posted on 01-31-2023 12:58 PM
Yes, you may need to put the full path to the plist though.
Posted on 02-02-2023 03:56 AM
@AJPintothank you for the hint, after fixing the path, it still does not return the expected result.
Posted on 01-31-2023 01:37 PM
@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>"
Posted on 02-01-2023 02:13 AM
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?
Posted on 02-01-2023 05:55 AM
@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"
Posted on 02-02-2023 12:20 AM
@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:
Posted on 02-02-2023 05:05 AM
@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?
Posted on 02-02-2023 05:20 AM
Posted on 02-02-2023 05:39 AM
@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>"
Posted on 02-03-2023 01:24 AM
@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>"