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


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

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