-
Notifications
You must be signed in to change notification settings - Fork 1
/
exta_icloud_status.sh
executable file
·59 lines (58 loc) · 2.69 KB
/
exta_icloud_status.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# exta_icloud_status.sh
#
# This extension attribute checks all users over UID 500 for their Keychain Sync and iCloud Drive / iCloud Document Sync status
# In Casper Results will look like this:
# Username=User1 KeyChainStatus=true DocSyncStatus=true
# Username=User2 KeyChainStatus=false DocSyncStatus=true
#
# Created by Andrew Seago on 11/11/14.
# set -x # DEBUG. Display commands and their arguments as they are executed
# set -v # VERBOSE. Display shell input lines as they are read.
# set -n # EVALUATE. Check syntax of the script but dont execute
#
#
## Variables
####################################################################################################
userList=(`dscl . -list /Users UniqueID | awk '$2 >= 500 { print $1; }' | grep -v -E '(messagebus|someuser|someohtheruser)'`)
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
ReconReport=''
## Script
####################################################################################################
for userAccount in ${userList[@]}; do
UserDir=`/usr/bin/dscl . read /Users/$userAccount NFSHomeDirectory | cut -c 19-`
if [ -e "$UserDir/Library/Preferences/MobileMeAccounts.plist" ]; then
if [ "$osvers" == '10' ] || [ "$osvers" == '11' ]; then
KeyChainStatus=`/usr/libexec/PlistBuddy -c "Print Accounts:0:Services:8:Enabled" "$UserDir/Library/Preferences/MobileMeAccounts.plist"`
DocSyncStatus=`/usr/libexec/PlistBuddy -c "Print Accounts:0:Services:0:Enabled" "$UserDir/Library/Preferences/MobileMeAccounts.plist"`
elif [ "$osvers" == '9' ]; then
KeyChainStatus=`/usr/libexec/PlistBuddy -c "Print Accounts:0:Services:7:Enabled" "$UserDir/Library/Preferences/MobileMeAccounts.plist"`
DocSyncStatus=`/usr/libexec/PlistBuddy -c "Print Accounts:0:Services:10:Enabled" "$UserDir/Library/Preferences/MobileMeAccounts.plist"`
elif [ "$osvers" == '8' ]; then
KeyChainStatus='NA'
DocSyncStatus=`/usr/libexec/PlistBuddy -c "Print Accounts:0:Services:7:Enabled" "$UserDir/Library/Preferences/MobileMeAccounts.plist"`
elif [ "$osvers" == '7' ]; then
KeyChainStatus='NA'
DocSyncStatus=`/usr/libexec/PlistBuddy -c "Print Accounts:0:Services:5:Enabled" "$UserDir/Library/Preferences/MobileMeAccounts.plist"`
else
KeyChainStatus='NA'
DocSyncStatus='NA'
fi
else
KeyChainStatus='NA'
DocSyncStatus='NA'
fi
if [ "$KeyChainStatus" == "" ]; then
KeyChainStatus='NA'
elif [ "$DocSyncStatus" == "" ]; then
DocSyncStatus='NA'
fi
if [ "$ReconReport" == "" ]; then
ReconReport="Username=$userAccount KeyChainStatus=$KeyChainStatus DocSyncStatus=$DocSyncStatus"
else
ReconReport="$ReconReport
Username=$userAccount KeyChainStatus=$KeyChainStatus DocSyncStatus=$DocSyncStatus"
fi
done
echo "<result>$ReconReport</result>"
exit 0