Hello All
Our organization would like to restrict the use of personal email accounts on our network. Outlook is, and should be the default/only mail client being utilized. I know I can select third party clients from the inventory on installed application but I need to identify computers that have attached their Gmail, Yahoo, etc accounts to the native Mac Mail client. Can anyone assist with the necessary criteria for a smart group or suggest another method of identifying those computers?
There is no built in criteria in Casper that will do this for you. But, you could build an Extension Attribute or 2 that would pull info on setup Mail accounts per user on the system and then you could use this for your Smart Group criteria.
I just put this script together. Not well tested, but give it a try.
#!/bin/bash
while read user; do
MailAccts=$(ls /Users/$user/Library/Mail/V2/ 2>/dev/null | egrep "IMAP|POP" | sed 's/^IMAP-//g;s/^POP-//g')
if [ ! -z "$MailAccts" ]; then
resultArray+=("$user: $MailAccts")
fi
done < <(ls /Users | grep -v "Shared")
if [[ "${resultArray[@]}" != "" ]]; then
echo "<result>$(printf '%s
' "${resultArray[@]}")</result>"
else
echo "<result>None</result>"
fi
It should hopefully pull the accounts that are set up per user and reports back. I'm specifically excluding Exchange accounts in this check, but that could be added as well if needed. Note that I only have an IMAP account set up on my Mac, so I can't check to see how some other accounts look once they've been set. But I think this should capture the most common types - IMAP and POP.
Note that I did not really research this much. There may be a plist file you can read with defaults or something that would get you the same info, though it would still be a unique plist per user account anyway.
Give this a try..
#!/bin/bash
# Name : show-MailEmailAccounts.sh
# Author : Nick Smith
# Date : 20150803
# Purpose : Query /Users//Library/Mail/V2/MailData/Accounts.plist for active email accounts.
# Variables
currentUser=`ls -l /dev/console | cut -d " " -f 4`
# Begin script
theResult=$(defaults read /Users/$currentUser/Library/Mail/V2/MailData/Accounts.plist DeliveryAccounts | grep "CanonicalEmailAddress" | awk '{print $3}' | sed 's/[";]//g')
/usr/bin/printf "
$theResult"
@Snickasaurus Ah, see I knew there was some plist somewhere with that info.
Unfortunately, the script you posted doesn't actually produce a result on my Mac. I can see the Accounts.plist "DeliveryAccounts" has data in the array, but there is no "CanonicalEmailAddress" entry in it, so doing a grep for that doesn't yield a result. And I have a Gmail account set up within Mail.app, so its there for sure.
I don't know if it has something to do with a different version of Mail.app. I'm trying this on 10.9.5. Maybe that only works on 10.10.x?
@tharr00 Give me a list of client versions in your environment so I can change the script up a bit.
Clients are 10.9.5 to 10.10.4 Thank you1
has anyone been successful with this?
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.