Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Created December 10, 2016 17:02
Show Gist options
  • Save talkingmoose/81d6d947e1dc46b9fe3c8d8c1afdbc7d to your computer and use it in GitHub Desktop.
Save talkingmoose/81d6d947e1dc46b9fe3c8d8c1afdbc7d to your computer and use it in GitHub Desktop.
Shell script to change current user's Outlook settings
#!/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
@talkingmoose
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment