Skip to main content

Hi,

It there a way to not allow users to sync their device with their personal iCloud? Ie not allowing icloud drive.

Thanks
Jared

Guess I'll need to go back and validate.  Looks like Apple has changed some of the keys in the plist.  I'll take a look at it tomorrow and report back.


Thanks in advance as I was thinking lost my mind. We have another one that's pretty old we use that seems to be accurate enough that I've posted it below, but we've used the one you wrote for a long time.

#!/bin/sh iCloudDrivePath="/Library/Mobile Documents/com~apple~CloudDocs" grabConsoleUserAndHome() { currentUser=$(stat -f %Su "/dev/console") homeFolder=$(dscl . read "/Users/$currentUser" NFSHomeDirectory | cut -d: -f 2 | sed 's/^ *//'| tr -d '\\n') case "$homeFolder" in *\\ * ) homeFolder=$(printf %q "$homeFolder") ;; *) ;; esac } grabConsoleUserAndHome if [[ "$currentUser" == "root" ]] then exit fi # Checks if the drive path and file exists if [[ -e "$homeFolder""$iCloudDrivePath" ]] then # Checks status of iCloud Drive Desktop and Documents setting iCloudDesktop=$(defaults read /Users/$currentUser/Library/Preferences/com.apple.finder.plist FXICloudDriveDesktop) if [[ "$iCloudDesktop" = 1 ]]; then echo "<result>"Drive Enabled - Desktop/Docs Enabled"</result>" else echo "<result>"Drive Enabled - Desktop/Docs Disabled"</result>" fi; else echo "<result>"Drive Disabled"</result>" fi exit 0

Thanks in advance as I was thinking lost my mind. We have another one that's pretty old we use that seems to be accurate enough that I've posted it below, but we've used the one you wrote for a long time.

#!/bin/sh iCloudDrivePath="/Library/Mobile Documents/com~apple~CloudDocs" grabConsoleUserAndHome() { currentUser=$(stat -f %Su "/dev/console") homeFolder=$(dscl . read "/Users/$currentUser" NFSHomeDirectory | cut -d: -f 2 | sed 's/^ *//'| tr -d '\\n') case "$homeFolder" in *\\ * ) homeFolder=$(printf %q "$homeFolder") ;; *) ;; esac } grabConsoleUserAndHome if [[ "$currentUser" == "root" ]] then exit fi # Checks if the drive path and file exists if [[ -e "$homeFolder""$iCloudDrivePath" ]] then # Checks status of iCloud Drive Desktop and Documents setting iCloudDesktop=$(defaults read /Users/$currentUser/Library/Preferences/com.apple.finder.plist FXICloudDriveDesktop) if [[ "$iCloudDesktop" = 1 ]]; then echo "<result>"Drive Enabled - Desktop/Docs Enabled"</result>" else echo "<result>"Drive Enabled - Desktop/Docs Disabled"</result>" fi; else echo "<result>"Drive Disabled"</result>" fi exit 0

From testing this one seems to work now.

#!/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" -ge "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 setting iCloudDriveStatus=$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.apple.finder.plist FXICloudDriveEnabled) #Variable to determine if a user is logged into iCloud "$plistBud" -c "print :Accounts:0:AccountID" /Users/"$loggedInUser"/Library/Preferences/MobileMeAccounts.plist > /dev/null 2>&1 iCloudSignInAccount=$(echo $?) #If an AccountID is not found if [[ "$iCloudSignInAccount" = "1" ]]; then DocSyncStatus="Disabled" else #If an Account ID is found iCloudSignInStatus="1" #Variable to determine if Drive is enabled driveStatus=$("$plistBud" -c "print :Accounts:0:Services:2:Enabled" /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist) #If account is signed in if [[ "$iCloudSignInStatus" = "1" ]]; then if [[ "$driveStatus" = "true" ]]; then DocSyncStatus="Enabled" fi if [[ "$driveStatus" = "false" ]]; then DocSyncStatus="iCloud Account Signed In, Drive Not Enabled" fi fi fi else DocSyncStatus="OS Not Supported" fi /bin/echo "<result>$DocSyncStatus</result>"

From testing this one seems to work now.

#!/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" -ge "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 setting iCloudDriveStatus=$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.apple.finder.plist FXICloudDriveEnabled) #Variable to determine if a user is logged into iCloud "$plistBud" -c "print :Accounts:0:AccountID" /Users/"$loggedInUser"/Library/Preferences/MobileMeAccounts.plist > /dev/null 2>&1 iCloudSignInAccount=$(echo $?) #If an AccountID is not found if [[ "$iCloudSignInAccount" = "1" ]]; then DocSyncStatus="Disabled" else #If an Account ID is found iCloudSignInStatus="1" #Variable to determine if Drive is enabled driveStatus=$("$plistBud" -c "print :Accounts:0:Services:2:Enabled" /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist) #If account is signed in if [[ "$iCloudSignInStatus" = "1" ]]; then if [[ "$driveStatus" = "true" ]]; then DocSyncStatus="Enabled" fi if [[ "$driveStatus" = "false" ]]; then DocSyncStatus="iCloud Account Signed In, Drive Not Enabled" fi fi fi else DocSyncStatus="OS Not Supported" fi /bin/echo "<result>$DocSyncStatus</result>"

Very nice and thank you for the work here. I put this in-place and it is working as expected.

Again, thank you!


 

hmm I can't seem to get it to show up


You have it listed under Hardware.

I am sure you know that by now.

Thank you!


here is the most updated version that I use today that works fine.  

#!/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" -ge "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>"

Sonoma compatibility?

I am seeing OS Not Supported on our clients now.

Thank you.


From testing this one seems to work now.

#!/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" -ge "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 setting iCloudDriveStatus=$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.apple.finder.plist FXICloudDriveEnabled) #Variable to determine if a user is logged into iCloud "$plistBud" -c "print :Accounts:0:AccountID" /Users/"$loggedInUser"/Library/Preferences/MobileMeAccounts.plist > /dev/null 2>&1 iCloudSignInAccount=$(echo $?) #If an AccountID is not found if [[ "$iCloudSignInAccount" = "1" ]]; then DocSyncStatus="Disabled" else #If an Account ID is found iCloudSignInStatus="1" #Variable to determine if Drive is enabled driveStatus=$("$plistBud" -c "print :Accounts:0:Services:2:Enabled" /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist) #If account is signed in if [[ "$iCloudSignInStatus" = "1" ]]; then if [[ "$driveStatus" = "true" ]]; then DocSyncStatus="Enabled" fi if [[ "$driveStatus" = "false" ]]; then DocSyncStatus="iCloud Account Signed In, Drive Not Enabled" fi fi fi else DocSyncStatus="OS Not Supported" fi /bin/echo "<result>$DocSyncStatus</result>"

It does seem to work fine.

Thank you again.