Find the Apple ID of the currently logged in user.
  • 25 Dec 2023
  • 1 Minute to read
  • PDF

Find the Apple ID of the currently logged in user.

  • PDF

Article Summary

The following Shell script helps IT Admins to see the Apple ID of the current logged in user on the managed Mac devices.

  1. Create a file on your desktop, for example, AppleID.sh and open it in a text editor like notepad++
  2. Copy the contents below to the file or click hereto download the file.
    Shell
    #!/bin/bash
    for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
        userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//')
        appleid=$(dscl . readpl "${userHome}" dsAttrTypeNative:LinkedIdentity appleid.apple.com:linked\ identities:0:full\ name 2> /dev/null | awk -F'full name: ' '{print $2}')
        if [[ "${appleid}" == "" ]]; then
            echo "User:${user} has not signed in with an Apple ID"
        else
            echo "User:${user} is signed in with AppleID:${appleid}"
        fi
    done

  3. Once the script is successfully executed you will see the Apple ID of the current logged in user in the View Status report > Output tab.


  4. Follow our guide to upload & publish the Shell script using Scalefusion Dashboard.

Please note that to use the Shell scripts, the Scalefusion MDM Client Application must be installed on the device(s). Please follow our guide to publish and install the Scalefusion MDM Agent Application.
Notes:
  1. The scripts and their contents are sourced from various albeit authenticated Apple Developer communities and forums.
  2. Please validate the scripts on a test machine before deploying them on all your managed devices.
  3. Scalefusion has tested these scripts, however, Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the incorrect usage of these scripts.




Was this article helpful?