Who is using iCloud - Command

stutz
Contributor

We are considering disabling iCloud within our organization but we want to know how many of our users are actually using it. Does anyone have a command or know of a policy that we can create to return back which computers have iCloud enabled?

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

I don't know if there's a specific command that would do that, but I just hacked a quick and dirty script together that would pull any iCloud account emails together along with the user they are associated with, and can be put into an Extension Attribute.
I only tested this on my Mac, and only with my iCloud account set up on it, so I have no idea how well it would work in a multi-user setup. It should pull a list of any users on the Mac with iCloud accounts set up. but I can't really test that.

Anyway, it might be a start. Here it is:

#!/bin/bash

for user in $(ls /Users/ | grep -v Shared); do
    if [ -d "/Users/$user/Library/Application Support/iCloud/Accounts" ]; then
        Accts=$(find "/Users/$user/Library/Application Support/iCloud/Accounts" | grep '@' | awk -F'/' '{print $NF}')
        iCloudAccts+=(${user}: ${Accts})
    fi
done

echo "<result>$(printf '%s
' "${iCloudAccts[@]}")</result>"

Just one thing. Since this pulls email addresses associated with the iCloud account, it might constitute an invasion of privacy in some environments, so just be sure you are allowed to even collect this data before doing anything like this. I know some Casper Suite customers have had to proactively disable many features of the product to have it allowed to be used in the company. For ex, even collecting application usage is a big issue with some labor unions in some countries.
OTOH, if that isn't an issue for you, you could use the data to email the person that you may in the future be disabling iCloud on your network, so they have a heads up on that.

View solution in original post

3 REPLIES 3

davidacland
Honored Contributor II

There's some info stored in ~/Library/Preferences/MobileMeAccounts.plist. Just tested logging in on a new Mac and the file gets created. Logging back out from iCloud and the file remains but most of the contents is removed.

I would create an extension attribute in Casper that reads the username out from that file using defaults read or plistbuddy, or just reports that it is enabled / logged in.

mm2270
Legendary Contributor III

I don't know if there's a specific command that would do that, but I just hacked a quick and dirty script together that would pull any iCloud account emails together along with the user they are associated with, and can be put into an Extension Attribute.
I only tested this on my Mac, and only with my iCloud account set up on it, so I have no idea how well it would work in a multi-user setup. It should pull a list of any users on the Mac with iCloud accounts set up. but I can't really test that.

Anyway, it might be a start. Here it is:

#!/bin/bash

for user in $(ls /Users/ | grep -v Shared); do
    if [ -d "/Users/$user/Library/Application Support/iCloud/Accounts" ]; then
        Accts=$(find "/Users/$user/Library/Application Support/iCloud/Accounts" | grep '@' | awk -F'/' '{print $NF}')
        iCloudAccts+=(${user}: ${Accts})
    fi
done

echo "<result>$(printf '%s
' "${iCloudAccts[@]}")</result>"

Just one thing. Since this pulls email addresses associated with the iCloud account, it might constitute an invasion of privacy in some environments, so just be sure you are allowed to even collect this data before doing anything like this. I know some Casper Suite customers have had to proactively disable many features of the product to have it allowed to be used in the company. For ex, even collecting application usage is a big issue with some labor unions in some countries.
OTOH, if that isn't an issue for you, you could use the data to email the person that you may in the future be disabling iCloud on your network, so they have a heads up on that.

stutz
Contributor

That script is exactly what I needed. I appreciate the help.