Created
December 10, 2016 17:02
-
-
Save talkingmoose/81d6d947e1dc46b9fe3c8d8c1afdbc7d to your computer and use it in GitHub Desktop.
Shell script to change current user's Outlook settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# get current active console user | |
shortName=$( /usr/bin/logname ) | |
# AppleScript command to set domain for console user in Outlook | |
command1="tell application \"Microsoft Outlook\" to set domain of Exchange account 1 to \"domainname\"" | |
# AppleScript command to set user for console user in Outlook | |
command2="tell application \"Microsoft Outlook\" to set user name of Exchange account 1 to \"$shortName\"" | |
# run both AppleScript commands as the current console user | |
sudo -u "$shortName" osascript -e "$command1" | |
sudo -u "$shortName" osascript -e "$command2" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Intended for use with something like Jamf's Self Service where the script will always run as root. The logname command will get the current console user name and the script will run commands as the user instead of root.