iCloud Drive Desktop and Documents Sync Status

__AMM
New Contributor II

Hi all,

I am currently facing a challenge and would appreciate your assistance. I am trying to identify which clients have iCloud Drive activated, specifically with synchronization of desktop and documents.

I have conducted extensive research online and within this forum, but it appears that the solutions provided are not applicable to the newer versions of macOS.

Could anyone provide guidance or suggest a method that would be effective for the latest macOS versions (Ventura, Sonoma)?

 

Any help would be greatly appreciated.

2 REPLIES 2

jamf-42
Valued Contributor II
#!/bin/bash

# Purpose: to grab iCloud Drive Desktop and Document Sync status.
# If Drive has been setup previously then values should be: "Enabled" or "Not Enabled"
# If Drive has NOT been set up previously then values will be: "iCloud Account Enabled, Drive Not Enabled" or "iCloud Account Disabled"

#Variable to determine major OS version
#OSverMinor="$(/usr/bin/sw_vers -productVersion | /usr/bin/cut -d . -f 2)"
#OSverMajor="$(/usr/bin/sw_vers -productVersion | /usr/bin/cut -d . -f 1)"
#Determine OS is 10.12 or greater as Doc Sync is only available on 10.12+
#if [ "$OSverMinor" -ge "12" ] || [ "$OSverMajor" -eq "11" ]; then
    #Path to PlistBuddy
    plistBud="/usr/libexec/PlistBuddy"
    #Determine logged in user
    loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
    #Variable to determine status of iCloud Drive Desktop & Documents setting
    iCloudDesktop=$(defaults read /Users/$loggedInUser/Library/Preferences/com.apple.finder.plist FXICloudDriveDesktop)
    #Determine whether user is logged into iCloud
    if [[ -e "/Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist" ]]; then
        iCloudStatus=$("$plistBud" -c "print :Accounts:0:LoggedIn" /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist 2> /dev/null )
        #Determine whether user has iCloud Drive enabled. Value should be either "False" or "True"
        if [[ "$iCloudStatus" = "true" ]]; then
            DriveStatus=$("$plistBud" -c "print :Accounts:0:Services:2:Enabled" /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist 2> /dev/null )
            if [[ "$DriveStatus" = "true" ]]; then
                if [[ "$iCloudDesktop" = "1" ]]; then
                    DocSyncStatus="Enabled"
                else
                    DocSyncStatus="Not Enabled"
                fi
            fi
            if [[ "$DriveStatus" = "false" ]] || [[ -z "$DriveStatus" ]]; then
                DocSyncStatus="iCloud Account Enabled, Drive Not Enabled"
            fi
        fi
        if [[ "$iCloudStatus" = "false" ]] || [[ -z "$iCloudStatus" ]]; then
            DocSyncStatus="iCloud Account Disabled"
        fi
    else
        DocSyncStatus="iCloud Account Disabled"
    fi
#else
#    DocSyncStatus="OS Not Supported"
#fi
/bin/echo "<result>$DocSyncStatus</result>"

not my code.. but.. used as an EA along with others.. 

__AMM
New Contributor II

Thanks, but something is not working properly with this script. The result for all systems is the same "iCloud Account Disabled" which is not correct