Posted on 10-05-2020 06:33 AM
Hi everyone, we need to see which apple id is being used on every device we have enrolled in jamf. For this I've created an extension attribute that seems to work but only for a few hours.
I don't understand why but after a while it goes from this:
to this:
and if I run a sudo jamf recon it goes back to normal for another while but after sometime it keeps going bad.
this is the script that I'am using:
appleid=$(/usr/libexec/PlistBuddy -c "print :Accounts:0:AccountID" ~/Library/Preferences/MobileMeAccounts.plist);
echo "<result>$appleid</result>"
exit 0
Do you have any suggestions or ideas about why this happening?
Thanks in advance
ps: I am pretty new to mac and jamf
Solved! Go to Solution.
Posted on 10-05-2020 06:48 AM
@matias.picco EAs run as root, so you can't use ~ to refer to the current user's home directory. Try this (note that if no user is logged in this EA isn't going to return anything useful, so you should add some logic to accommodate that):
!/bin/bash
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
appleid=$(/usr/libexec/PlistBuddy -c "print :Accounts:0:AccountID" /Users/$currentUser/Library/Preferences/MobileMeAccounts.plist);
echo "<result>$appleid</result>"
exit 0
Posted on 10-05-2020 06:48 AM
@matias.picco EAs run as root, so you can't use ~ to refer to the current user's home directory. Try this (note that if no user is logged in this EA isn't going to return anything useful, so you should add some logic to accommodate that):
!/bin/bash
currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
appleid=$(/usr/libexec/PlistBuddy -c "print :Accounts:0:AccountID" /Users/$currentUser/Library/Preferences/MobileMeAccounts.plist);
echo "<result>$appleid</result>"
exit 0
Posted on 10-06-2020 12:05 PM
Thanks sdagley! It seems to be working now. Since yesterday the info didn't go corrupt on the pc we are using for testing and it also started populating in other devices so it should be ok from now on. Thanks