Outlook 2016 autoconfigure

hkabik
Valued Contributor

Now that the schedules tab is removed from Outlook's preferences... has anyone figure out a way to apply a self configuration script like this one?

https://github.com/talkingmoose/Outlook-Exchange-Setup

Our users really enjoyed everything being automagically configured.

1 ACCEPTED SOLUTION

talkingmoose
Moderator
Moderator

More stuff ready for anyone who'd like to test...

I've devised a launchd setup that works well for me in my testing to automatically configure Outlook 2016 the first time it's launched. After a lot of research into launchd QueueDirectories and WatchPaths, the WatchPaths made the most sense because I can monitor for the existence of specific files. (Thanks, @eholtam, for your ideas. I adapted them for my own changes.)

The whole setup consists of one LaunchAgent file and two scripts. The only file you need to customize is the AppleScript. Everything else can just drop in place. The ROOT folder simply designates the "root" of the hard drive or "/". For now, be sure to keep the names and paths of the files and folders the same as I've created them unless you're comfortable changing the references in the three files.

I've also made minor changes to the AppleScript itself to better accommodate all potential settings not just Active Directory as well as accommodate this new setup.

You'll find everything here: https://github.com/talkingmoose/Outlook-Exchange-Setup-5.0

Click the Download ZIP button to the bottom right and locate these files in the ROOT folder:

  • /Library/LaunchAgents/net.talkingmoose.OutlookExchangeSetupLaunchAgent.plist
  • /Library/Talking Moose Industries/Scripts/Outlook Exchange Setup 5.0.scpt (customize this)
  • /Library/Talking Moose Industries/Scripts/OutlookExchangeLaunchAgent.sh

Feedback, as always, is greatly appreciated.

View solution in original post

220 REPLIES 220

benbass
New Contributor III

@tim.rees Oh, I do have it in git - in a private repo. So I will fork again, and sanitize the scripts for general consumption.

tim_rees
Contributor

As a temporary fix i've add the following in at the start of the OutlookExchangeSetupLaunchAgent.sh file:

# Create $HOME/Library/LaunchAgents if it does not exist username=$(ls -l /dev/console | awk '{print $3}') if [ ! -d "$HOME/Library/LaunchAgents" ] then sudo -u $username /bin/mkdir -m 0700 "$HOME/Library/LaunchAgents" fi

Edit: I just found there is a line for creating the LaunchAgents folder in the .sh file... I don't know why it didn't work before.. but it seems to be working now...

tim_rees
Contributor

@benbass @talkingmoose Either of you encountered the LaunchAgents put into ~/Library/LaunchAgents appearing to be duplicated in /Library/LaunchAgents in a fresh install of 10.11.2? I thought I was going slightly insane.

benbass
New Contributor III

@tim.rees I haven't seen that particular thing happen. But I finally have my whole setup complete - so tomorrow I will anonymize it and post it up on github. It is based off of @talkingmoose setup but uses scripts instead of profiles for setting things and I have tweaked his AppleScript, but is is mainly his hard work.

I'll post here once I get that up.

talkingmoose
Moderator
Moderator

@tim.rees, that wouldn't be something caused the scripts (latest version 5.1.0). Not sure what would be causing duplication. They are duplicated not just created in the wrong place?

Let's not let go of that insanity idea just yet. For my sake. ;-)

tim_rees
Contributor

Hey @talkingmoose

I was about to post with my further findings...

Ignore everything I ever said!!!!! :-)

I re-downloaded the scripts from scratch, removed the launchctl command from the postflight script, and it worked first time! I think the problem was between the keyboard and the chair!

Thanks for the scripts @talkingmoose and thanks for the help @benbass :-)

Carlos
New Contributor

Hi All...This may not be the right spot for this question as it's a bit off topic but haven't been able to find a discussion out there that covers it...

So the scenario I am working with is this:

Corp environment running Office 2011, Outlook 2011 connected to Exchange accounts, Users have moved some emails into "On My Computer" folders in an attempt to archive emails off of the live Exchange boxes. Therefore users open Outlook and they are Connected to Exchange and also have local "On My Computer" folders with email.

We are now working with upgrading/migrating these users to Office 2016....I am looking for a automated/scripted method to either A. Install Office 2016 side by side with Office 2011 and then import the contents of the "Microsoft User Data" folder for Outlook 2011 to the new "Identities" location for Outlook 2016 to bring over all emails contained within "On My Computer" as well as the Exchange account. Or B. Backup the "Microsoft User Data" folder for Outlook 2011, uninstall Office 2011, Install Office 2016 and then restore the backup made of the "Microsoft User Data" folder into Outlook 2016 to bring over the "On My Computer" folders as well as the Exchange account.

Let me know what you guys think...thanks in advance :)

talkingmoose
Moderator
Moderator

@Carlos, right now, Outlook 2016 has no scripted way of importing an Outlook 2011 identity. It's going to have to be a manual process run by someone using Outlook.

Outlook 2016 will import a 2011 identity if you choose File > Import > Outlook 2011 data on this computer.

FYI, Outlook 2016 when used with Office 365 or Exchange now supports Online Archive if your administrator has enabled it for your accounts. You'll still need to move those On My Computer messages manually back to your Exchange account, however, going forward the server will automatically move them to the Online Archive mailbox for that user. This mailbox is not synchronized to Outlook. It's a great way to access old messages without consuming your primary mailbox's quota.

So, short answer. You'll still feel some pain now, but getting your users upgraded will help you feel a lot less pain later.

Platzhirsch89
New Contributor

Hi, first of all, i want to thank talkingmoose for this amazing script!! Thank you! Im new in this forum and the conversations here many time helped me out of problems so i have decided to join this forum. About this script i have a question: it work fine in my enviroment with el capitan, but the account in outlook dublicates himself every time i restart outlook and after several times opening, i got 5 identical accounts. Do you have any idea what could be the issue? I reinstalled the mac several times but still the same problem. thank you for your help!

tnielsen
Valued Contributor

Good job talkingmoose.

mapurcel
Contributor III

@talkingmoose we are also in the situation of having our users import the 2011 identity, including the account. As we are going to o365, we need to change the username from domainusername to UPN (or email address) on the account that is being imported. Can you point me in the right direction on if this is possible or if we will need to create a new account? And if we create a new account is there a way to make the username the UPN instead of the short name or domainusername? thanks in advance

talkingmoose
Moderator
Moderator

@mapurcel, Outlook 2016's built-in import/upgrade feature won't migrate IMAP or Exchange mail/calendar/contact data. It will only migrate account settings and preferences such as rules, categories and signatures. Microsoft expects the mail to download from the server.

Because the import cannot be scripted, you or your user will need to launch Outlook 2016 and start that process manually (or it may kick in as part of the first launch of Outlook). But you'll then have to change account settings too.

My suggestion is to start new accounts and be sure to educate users they will need to recreate those preferences I mention above.

talkingmoose
Moderator
Moderator

@eholtam has corrected me on Outlook 2016's behavior when importing Outlook 2011 mail data. It will import mail data directly instead of downloading data from the servers again.

AdamH
New Contributor II

This is a great script. When we rolled out version 15.17 it was working flawlessly.
But when we went to 15.18, we got a new odd behavior.
Everything works correctly, the agent sets up the account when Outlook is launched and prompts for the user's password as it always has.
The difference now is that the account doesn't actually log in.
The account is setup correctly but doesn't start downloading email.
If you quit outlook and relaunch it, the mail starts populating as you might expect.
Has anyone seen this behavior before?

talkingmoose
Moderator
Moderator

@AdamH, not sure about the behavior you're seeing with the newer version of Outlook, but you may be able to kickstart the login by adding a couple of lines at the end of the script to set Outlook to work offline and then online again.

tell application "Microsoft Outlook" to set working offline to true
tell application "Microsoft Outlook" to set working offline to false

kbach
New Contributor

@AdamH I am seeing the behavior you're describing on Outlook 15.19.1.

I also took the liberty of toggling from online to offline within the first time Outlook being launched after entering password, it has no affect. Only after closing Outlook and relaunching do I get a secondary prompt to enter password and then the mailbox begins to sync.

apizz
Valued Contributor

@AdamH @kbach seeing the same behavior for me as well on 15.21.1.

Immediately after entering the account password when I go into account settings there's no password entered. When I quit and reopen it prompts again and when I enter the password this time it immediately starts syncing mail. Put in this in an issue on Github.

kstrick
Contributor III

have seen the same behavior intermittently with 15.21.1

apizz
Valued Contributor

Using the updated 5.3 AppleScript from Github and adding a delay 5 before the end tell for Microsoft Outlook resolved our issue. Script is now working like a thing of beauty.

Thanks for making my and my team's lives for our image next year that much easier! <3

cskj
New Contributor II

This is an awesome script! I have so much to learn from this!

I'm curious if anyone here has had any luck scripting the S/MIME certificates anywhere for Outlook 2016.

I see both options to enable smime encryption and signing in apple script and can set those, but without a cert selected it defeats the purpose.

Would you be able to point me in the right direction for that one?

talkingmoose
Moderator
Moderator

@aporlebeke, so glad to hear the delay is working. You might try a shorter delay if you feel the timing is a little slow. I'll do some testing and consider adding this to the AppleScript.

@cskj, unfortunately, the only encryption/certificate settings that are scriptable don't include configuring the account to use them. While Microsoft will continue supporting the existing AppleScript code in Office for Mac, it has said it will no longer continue development. That means we're more than likely not going to see the necessary properties added to Outlook's dictionary to script enabling certificates.

wmateo
Contributor

@talkingmoose This is a great script! thank you for creating it. I am having trouble using it in my environment as the DOMAINusername method does not work even when done manually. It accepts username@domain (which differs from the email domain). Any suggestions?

other than that, the script works very well.

talkingmoose
Moderator
Moderator

@wmateo, you're more than likely looking for User Principal Name (UPN). Assuming you're connecting to Active Directory, you can read this from the directory and use it directly. Do this:

  1. Look for this section under "Begin collecting user information":
    set userFirstName to ""
    set userLastName to ""
    set userDepartment to ""
    set userOffice to ""
    set userCompany to ""
    set userWorkPhone to ""
    set userMobile to ""
    set userFax to ""
    set userTitle to ""
    set userStreet to ""
    set userCity to ""
    set userState to ""
    set userPostalCode to ""
    set userCountry to ""
    set userWebPage to ""
    set userPrincipalName to "" < -- Add this line
  2. Look for this section too. Add "userPrinicpalName" to the end.
    set userInformation to do shell script "/usr/bin/dscl "/Active Directory/" & netbiosDomain & "/All Domains/" -read /Users/$USER AuthenticationAuthority City co company department physicalDeliveryOfficeName sAMAccountName wWWHomePage EMailAddress FAXNumber FirstName JobTitle LastName MobileNumber PhoneNumber PostalCode RealName State Street userPrincipalName"
  3. Lower in the same section, find one of the several script blocks that looks like the following, duplicate it and modify it for userPrincipalName:
        set AppleScript's text item delimiters to {": "}
    if paragraph i of userInformation begins with "dsAttrTypeNative:userPrincipalName:" then
        try
            set userUPN to text item 2 of paragraph i of userInformation
        on error
            set AppleScript's text item delimiters to {""}
            set userUPN to characters 2 through end of paragraph (i + 1) of userInformation as string
        end try
    end if
  4. Look for the "Begin logging user information" section and modify it:
    writeLog("User information...")
    writeLog("First Name: " & userFirstName)
    writeLog("Last Name: " & userLastName)
    writeLog("User Principal Name: " & userUPN) < -- Add this line
    writeLog("Email Address: " & emailAddress)
    writeLog("Department: " & userDepartment)
    writeLog("Office: " & userOffice)
    writeLog("Company: " & userCompany)
    writeLog("Work Phone: " & userWorkPhone)
    writeLog("Mobile Phone: " & userMobile)
    writeLog("FAX: " & userFax)
    writeLog("Title: " & userTitle)
    writeLog("Street: " & userStreet)
    writeLog("City: " & userCity)
    writeLog("State: " & userState)
    writeLog("Postal Code: " & userPostalCode)
    writeLog("Country: " & userCountry)
    writeLog("Web Page: " & userWebPage)
    writeLog(return)
  5. Finally look for this section under "Begin account setup" and modify "user name" to use userUPN:
        try
        set newExchangeAccount to make new exchange account with properties ¬
            {name:"Mailbox - " & userFullName, user name:userUPN, full name:userFullName, email address:emailAddress, server:ExchangeServer, use ssl:ExchangeServerRequiresSSL, port:ExchangeServerSSLPort, ldap server:DirectoryServer, ldap needs authentication:DirectoryServerRequiresAuthentication, ldap use ssl:DirectoryServerRequiresSSL, ldap max entries:DirectoryServerMaximumResults, ldap search base:DirectoryServerSearchBase, receive partial messages:downloadHeadersOnly, background autodiscover:disableAutodiscover}
        my writeLog("Create Exchange account: Successful.")
    on error

I haven't tested these changes myself, but I think these should be all you need to do.

wmateo
Contributor

You are the man!! Thank You!! worked like a charm. @talkingmoose

Jaxson75
New Contributor II

On the OutlookExchangeSetupLaunchAgent.plist do I have to edit anything in there in order for the scripts to work. When I launch Outlook 2016 the scripts are not kicking in unless I run the Apple Script manually.

talkingmoose
Moderator
Moderator

@Jaxson75, you'll find a log in the user's ~/Library/Logs folder. What does it say?

dpratl
Contributor II

Thank you @talkingmoose this is awesome.

I just have one question, we are also deploying office templates and because of this the /Users/$USER/Library/Group Containers/UBF8T346G9.Office folder already exists. I tried to change some parts in your OutlookExchangeSetupLaunchAgent.sh to check the /Users/$USER/Library/Group Containers/UBF8T346G9.Office/Outlook folder but it didn't work.

Honestly I'm no programer i just tried ;)

Hope you or anyone else has a hint for me.

Thank you
BR
Daniel9577cace4ca8483ab4016c423ef2fcb8

talkingmoose
Moderator
Moderator

@dpratl, thanks for the kudos!

First, no need to deploy templates to each user's home folder. You can place them in /Library/Application Support/Microsoft/ for all users. See this document: http://macadmins.software/docs/UserContentIn2016.pdf.

The OutlookExchangeSetupLaunchAgent.sh script is looking for the existence of this folder in the current user's home folder: "$HOME/Library/Group Containers/UBF8T346G9.Office" You've identified that part perfectly. If it's already there then the script assumes the user already has Office preferences and setup doesn't happen.

You can correct this one of two ways:

  1. You can move your template files to the /Library/Application Support/Microsoft folder that I mentioned above and then remove the "$HOME/Library/Group Containers/UBF8T346G9.Office" from each user folder.
  2. You can try modifying this part of the script and see if that works.
    Change:

    if [[ -f "$HOME/Library/Group Containers/UBF8T346G9.Office/OutlookProfile.plist" ]] ; then
        logresult "$HOME/Library/Group Containers/UBF8T346G9.Office/OutlookProfile.plist already exists. Doing nothing." "$HOME/Library/Group Containers/UBF8T346G9.Office/OutlookProfile.plist does not exist but it should exist already. Something may be wrong."
    fi

    to:

    if [[ -f "$HOME/Library/Group Containers/UBF8T346G9.Office/OutlookProfile.plist" ]] ; then
        logresult "$HOME/Library/Group Containers/UBF8T346G9.Office/OutlookProfile.plist already exists. Doing nothing."
    else
        /usr/bin/touch "$HOME/Library/Group Containers/UBF8T346G9.Office/OutlookProfile.plist"
        logresult "$HOME/Library/Group Containers/UBF8T346G9.Office/OutlookProfile.plist does not exist but it should exist already. Creating the file."
    fi

dpratl
Contributor II

Thank you @talkingmoose - awesome scripts and super fast response time :D

I have to put the templates into that folder because if i don't Word and Outlook doesn't use them as default template. (Excel and PowerPoint are not working till now but at least Outlook and Word ;)

I did the changes you suggest but it looks like the script is not starting at all (also no entry into your log file)
If i run it per hand it is writing that it creates the plist file and launch agent.

I'm sorry to bother you because of my damn templates.

talkingmoose
Moderator
Moderator

@dpratl, be sure to test this setup for a user under a different OS X user account.

If your user logs in, the launch agent in /Library/LaunchAgents should trigger the shell script. Even if Outlook is already configured, that shell script should say something in the log. Having an empty log tells me the launch agent isn't running at login.

Launch agents require very specific ownership and permissions, which the installer should set. If you view these settings in Terminal, you should see something like:

ls -l /Library/LaunchAgents/
total 40
-rw-r--r--  1 root  wheel  595 Jul 26 07:58 net.talkingmoose.OutlookExchangeSetupLaunchAgent.plist

ocla__09
Contributor

Hi @talkingmoose Do you have any insight as to whether there is a way to suppress the following autodiscover prompt? There is apparently a reg key hack for Windows, but I have not seen anything for macOS at this point.
9a90215d827042b8a16bfe80b37561a7

talkingmoose
Moderator
Moderator

@ocla&&09, that's a user setting and I'm pretty sure it's stored in Outlook's SQLite database within its identity. I wouldn't attempt modifying the database or you may cause Outlook to rebuild it.

Other than the user clicking the Allow button and enabling the option to always use that response, you can run an AppleScript command. However, it requires Outlook be running under the user's account. The command is:

tell application "Microsoft Outlook" to set background autodiscover of exchange account 1 to false

You can replace the 1 with the actual name of the account if you have more than one.

Careful with doing this, though. If the user travels, you could disable Outlook from connecting when it attempts to connect from external networks.

I completely get this feature is confusing to users and suggest you voice your concern to Microsoft here: https://outlook.uservoice.com/forums/293343-outlook-for-mac/suggestions/12255774-autodiscover

ocla__09
Contributor

Thank You @talkingmoose, does this also disable autodiscover from the perspective of setting up a new account on a machine in the account prefs window (ie all or nothing), or is this just the background checks after the fact that the command verbage implies?

talkingmoose
Moderator
Moderator

@ocla&&09, you won't be able to disable Autodiscover until you have an Exchange account created. To work around that, you can use AppleScript to set Outlook to work offline, create the account, disable Autodiscover and then set Outlook to work online again.

tell application "Microsoft Outlook"
    set working offline to true
    set background autodiscover of exchange account 1 to false
    set working offline to false
end tell

Haven't tested this, but I think it's the right syntax.

AdamH
New Contributor II

First off... I love my Talking Moose script....
I love it even more because its called Talking Moose.... I remember that app.....

But apparently we are doing a slow phased migration to Office 365. So Hard-coding the exchange server in the script doesn't work for everyone and I have no way of discerning who has been migrated already. AutoDiscovery should work but that doesn't seem to be an option in the current script. Is there a way to use auto-configure with this script- or is that a whole new project?

talkingmoose
Moderator
Moderator

@AdamH, I love hearing someone remembers the app! It was the first computer program that showed me computers could be fun.

I wrote the script for environments where Autodiscover wasn't available. At the time I was using it, I was educating my Exchange folks about Autodiscover, but they were pretty slow to enable it.

Outlook's AppleScript dictionary does support calling Autodiscover:

tell application "Microsoft Outlook"
    autodiscover email address "bill@talkingmoose.net" user name "bill@talkingmoose.net"
end tell

It returns something like:

{use ssl:true, server:"https://outlook.office365.com/EWS/Exchange.asmx",
primary smtp address:"bill@talkingmoose.net",
oab manifest url:"https://outlook.office365.com/OAB/2d1f6b5f-c74d-0000-b7f4-fbbda4ee8c30/",
port:443, full name:"William M. Smith", ldap server:""}

I've just never considered modifying the script to support Autodiscover if it already works. It would take a bit of work to redo the script to support Autodiscover (maybe version 6.0?), but if you're familiar with how to take the output above and slip it into the properties at the top of the script, then that should be all you need.

AdamH
New Contributor II

Completely understand. If it were up to me, I'd have people just input their name and email and be done with it. But the script has spoiled the user base so much now that the expectation is that they will only need to input a password to start using Outlook.

I'm not a great scripture, but I do ok modifying other people's scripts, so the pointers you gave here should give me a good start. Thanks a bunch!
42031d2990934903924dc3d83070652c

AdamH
New Contributor II

OK, this is going to be trickier than I thought.

Without dealing with variables, I thought it may look something like:

tell application "Microsoft Outlook"
    try
        set exchnageInfo to autodiscover email address "mac.user@domain.com" user name "macuser1"


        set newExchangeAccount to make new exchange account with properties {exchangeInfo}


    end try

end tell

It calls up the right information and prompts for credentials like it may be expected to, but it doesn't actually create the account with that info.

rickwhois
Contributor

@talkingmoose this is awesome! I only have one issue. When I configure using this script, I can't seem to show shared calendars when I choose Open Shared Calendar. However, if I were to remove the account, and add it manually, I can Open Shared Calendars just fine. Is this happening to anyone else?

talkingmoose
Moderator
Moderator

Thanks for the kudos, @rickwhois!

No idea why configuring using a script vs. manual would affect opening shared calendars. Are you sure you're using the exact same settings?

Also, have you disabled Autodiscover in the script? That might cause this behavior, but I haven't tested.