what is the current Apple ID on the Mac?

Moe_Halabia
New Contributor II

Hi all
Is there any way that we can find out what is the current Apple ID on the Mac ??

1 ACCEPTED SOLUTION

stevewood
Honored Contributor II
Honored Contributor II

@mo.halabia

I use the following EA to grab the user signed into iCloud:

#!/bin/sh
## Get logged in user
loggedInUser=$(stat -f%Su /dev/console)
icloudaccount=$( defaults read /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist Accounts | grep AccountID | cut -d '"' -f 2)
if [ -z "$icloudaccount" ] 
then
    echo "<result>No Accounts Signed In</result>"
else
    echo "<result>$icloudaccount</result>"
fi

View solution in original post

4 REPLIES 4

stevewood
Honored Contributor II
Honored Contributor II

@mo.halabia

I use the following EA to grab the user signed into iCloud:

#!/bin/sh
## Get logged in user
loggedInUser=$(stat -f%Su /dev/console)
icloudaccount=$( defaults read /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist Accounts | grep AccountID | cut -d '"' -f 2)
if [ -z "$icloudaccount" ] 
then
    echo "<result>No Accounts Signed In</result>"
else
    echo "<result>$icloudaccount</result>"
fi

Moe_Halabia
New Contributor II

@stevewood

thanks a lot works just fine

St0rMl0rD
Contributor III

Thanks for the script, works great. However, it would be awesome if the results could be written into a file (let's say, on a server). How would one achieve that, without having to go through each individual Mac in the logs of the script to check for the results?

DT_India
New Contributor

This can be done with ExtensionAttribute. But sadly, I am no expert in this and would like to know how to do it.