Skip to main content
Solved

what is the current Apple ID on the Mac?

  • February 15, 2021
  • 4 replies
  • 31 views

Forum|alt.badge.img+4

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

Best answer by stevewood

@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

4 replies

stevewood
Forum|alt.badge.img+35
  • Hall of Fame
  • 1799 replies
  • Answer
  • February 15, 2021

@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

Forum|alt.badge.img+4
  • Author
  • New Contributor
  • 4 replies
  • February 18, 2021

@stevewood

thanks a lot works just fine


Forum|alt.badge.img+12
  • Valued Contributor
  • 297 replies
  • October 26, 2021

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?


Forum|alt.badge.img+1
  • New Contributor
  • 4 replies
  • April 26, 2023

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