Skip to main content

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 to this.


He did a preso, that is on youtube, were he said he was working on it.. However with Apple sandboxing you never know.



C


Yeah, i think @talkingmoose got the script to more or less work,
but I think triggering is the whole problem...
i was thinking of maybe creating a launchagent/launchdaemon to run that script that would run once when Outlook starts up, but not sure how smoothly it would work...
maybe trigger on creation of a /Users/USERNAME/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles folder?


Yes, launchd using watched files/folders seems to be working well in my testing so far. The issue I've had to overcome is the welcome window. Easy to do with configuration profiles and a little GUI scripting. Still working on this but that's the method I'm looking at using right now.


Good to know. I was thinking I could work my way around any changes to the script itself but for the life of me I couldn't figure out a reliable trigger method. Great to know you're on top of it! Thanks for your hard work!


@talkingmoose



Any news on a new version of the Outlook Exchange Setup script for Office 2016?


This is still a work in progress, but I've uploaded what I have so far to GitHub.



https://github.com/talkingmoose/Oulook-Exchange-Setup-5.0



The AppleScript itself should be ready for those who use it standalone as a double-clickable script or add it to Self Service. You'll find it in "ROOT/Library/Talking Moose Industries/Scripts/Outlook Exchange Setup 5.0.scpt".



What's not done yet is the launchd agent to trigger the script at first launch of Outlook. I'm still trying to find the right combination of items for the agent to watch.



Also, the guide is only updated through about page 24.



The overarching method I'm using is:




  1. Use a configuration profile to suppress the Outlook first run window. This works so far.

  2. Use a launchd agent to watch specific folders to know Outlook has been launched. Then run the script.

  3. From there, the script runs the same as older versions with a handful of changes.



As I make more progress I'll post more. For the time being, anyone who'd like to test the AppleScript part of the solution is more than welcome.


@talkingmoose, thank you!


@talkingmoose



I've been playing around with a version of the old script that i've modded,
and so far i've had decent luck with a launchagent that watches the following path--
it seems to trigger pretty quickly when you launch Outlook.



~/Library/Containers/com.microsoft.Outlook/Data/Library/Caches/com.microsoft.Outlook/Cache.db-shm

@talkingmoose Is there a way to change the Outlook "Account Description"? Making everyone's Outlook say "Microsoft Exchange" would be nice.



Changing "use Kerberos" to false sets the Outlook Account Description to "Untitled Exchange account".


@kstrick As far as I can tell in my testing, this path:



~/Library/Containers/com.microsoft.Outlook/


doesn't exist on a Mac that has not already had and run Outlook on it previously, so in the case of setting up newly setup/imaged Macs with Office 2016 installed on them, I don't think it'll be possible to use that full path as a WatchPath for the LaunchAgent. The directory doesn't get created as part of the Office installation, only when Outlook first gets launched, and that point its too late.
Launchd's WatchPath function can only watch items (files/folders) that exist. If its not there, the LaunchAgent won't use it as a trigger, and actually removes the path from its internal list of items to watch. @gregneagle has a writeup on this from his blog from years back. (blast from the past) I will have to double check on this, but I believe this rule of launchd jobs is still valid today.



There is the QueueDirectories item for launchd, but the thing about them is that it only works if the directory is not empty, so you can't, for example, use a path like /Library/Containers/ since its already populated with other directories.



I did a little experimenting on this though, and it seems its possible to pre-create the ~/Library/Containers/com.microsoft.Outlook/ directory along with an Office 2016 installation, say as a script run "After", leave the directory empty and then load a user level LaunchAgent watching that directory with QueueDirectories. As long as the permissions are set correctly on the folder, Outlook drops files into that dir upon first launch, and it fires the script pretty quickly. My test script simply put up a basic dialog so I knew it was working. However, as long as the directory remains non empty, the LaunchAgent will continue to run on whatever interval its set to (10 seconds by default unless otherwise specified) so the script would need to run the setup of the account, then either remove itself, or disable the LaunchAgent so it won't run again. Its possible to do, but would take some work and experimenting to get it right.



Edit: I just ran another quick test, and this is even easier than I first thought. While you can't use WatchPaths, you can use QueueDirectories and not even bother to pre-create that folder. Load the LaunchAgent that uses the path of ~/Library/Containers/com.microsoft.Outlook/ as the directory for QueueDirectories. As soon as Outlook launches it creates that directory and the script specified in the LaunchAgent fires. So no need to create the directory ahead of time.


@kstrick, I ran into the same issue you saw with WatchPaths and was considering watching ~/Library/Containers. WatchPaths should only be watching the top level folder and this area shouldn't really change that frequently. And then as part of the script, I was considering adding a check for existing files at the beginning of the script. The presence or absence of those files would determine whether the rest of the script actually executed.



However, based on your results with QueueDirectories, I'll definitely take a looksee there! If that's all it takes, well, the rest is just commentary to complete. :-)



Thanks for the sleuthing and testing!


@Abdiaziz, search within the script and locate this section:



set newExchangeAccount to make new exchange account with properties ¬
{name:"Mailbox - " & userFullName...


The "name" here is the name of the account. You can change this part of the script to what suits your needs. I originally choose this because it mirrored Outlook for Windows.


@mm2270, my comment to @kstrick should've been directed toward you. Sorry for the confusion.


@talkingmoose, I did see that part before posting and modified it, the results were the same "Untitled Exchange account". It's being overwritten by something and I need to find out what.


Thanks everyone for your efforts with this, especially @talkingmoose .



The script works great when I run it manually once the Outlook first run windows are disabled. I modified the LaunchAgent .plist to use the QueueDirectories key instead of WatchPaths, but when I went to load the LaunchAgent I see the following errors:



UserEventAgent Ignoring path: ~/Library/Containers/com.microsoft.Outlook/
com.apple.xpc.launchd[1] (net.talkingmoose.OutlookExchangeSetup5.0[8528]): Service exited with abnormal code: 1



I'll keep testing and let you know if I get it working.



Also, how do you figure out the AppleScript options for Outlook 2016? After an Exchange account is created Outlook appears to set the Preferences -> General -> Hide On My Computer folders to On. This setting prevents the creation of Contact Groups so I'd like to turn it off, do you think that would be possible with AppleScript?



PS. The Github repository is missing the 't' in Outlook (https://github.com/talkingmoose/Oulook-Exchange-Setup-5.0) ;)



EDIT: The AppleScript to turn off Hide On My Computer folders ended up being pretty obvious: "set hide on my computer folders to false"


Many thanks to @talkingmoose for the script! Very helpful. :)



Did anyone figure out how to change the first day of a week to Monday in Outlook? That's the last setting I'm not able to set.


@plawrence Can you post how your LaunchAgent looks here? I was not seeing an error in my testing using QueueDirectories and the path to the com.microsoft.Outlook container directory. Its possible you just need to adjust the LaunchAgent to get it to work.


@mm2270 @talkingmoose Good point on the QueueDirectories in lieu of WatchPaths,
that should work much better.


@mm2270 I started with the .plist template from @talkingmoose Github repo and just modified the WatchPaths to QueueDirectories. I then tried cutting out some of the parts (the RunAtLoad and the Environment Variables) to figure out where the error was and ended up with:



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>net.talkingmoose.OutlookExchangeSetup5.0</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>"/Library/Outlook Setup Script/Outlook Exchange Setup 5.0.scpt"</string>
</array>
<key>QueueDirectories</key>
<array>
<string>~/Library/Containers/com.microsoft.Outlook/</string>
</array>
</dict>
</plist>


I am testing this on 10.11 too if that helps. Let me know if you spot anything wrong!


@plawrence I can't say I see anything particularly wrong with the plist you posted above. The QueueDirectories section looks identical to the one I used in testing. There are other differences in mine, but that's because I created it myself in LaunchControl, not downloaded the one from the github page.



You said you edited yours and I'm wondering what method you used to edit it, and if you made sure to correct permissions on the plist file afterwards. Launchd jobs are very particular about ownership and perms on these configuration plists it uses.



Another question is, did you try using the LaunchAgent prior to making the edit, and if so, was it working or loading correctly at that point? I'm wondering if it just wasn't working from the start for you or if its somehow the edit of the plist that's causing it not to load now.



FWIW, I created a completely new LaunchAgent that uses QueueDirectories to watch for a non existent folder I just made up, loaded the agent, then created the directory and touched a file to it and it ran the associated script immediately, so the process of using QueueDirectories to look for a folder being created and populated seems to work very nicely. Just need to make sure the launchd job gets disabled afterwards or the script is removed so it doesn't keep running over and over. That's the only pickle left with this to work through.


@talkingmoose
I've been looking over your Outlook setup script. Great work on this as usual!



While examining it, I wondered if there was some way to make Outlook simply use the Autodiscover process to set up an Exchange account. Right now our Macs are all joined to AD, and all accounts are AD cached mobile. Users typically launch Outlook, go into Accounts, click on the Exchange button and enter their basic credentials, like Domainusername, email address and password, leave the Configure automatically button checked and it figures out the rest to set up their Exchange account.
Is there some way with Applescript to simulate this process in Outlook, so for example. all they would need to do is enter their password (since we can get the rest of the information from their cached AD mobile account)?


@plawrence
Not sure why but when I made my LaunchAgent it didn't seem to work when I had direct commands but as soon as I referenced a script directly it worked (I used a shell script for me configuration).
Also I didn't have the



        <key>Disabled</key>
<false/>


In my one.


@mm2270 I must be doing something wrong as I still cant get the LaunchAgent to work!



I've tried the following on both 10.11 and 10.10.5:
- Created a new LaunchAgent .plist using Lingon 3 to make sure there were no syntax errors, it had the following contents:



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>label</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>/Library/Outlook Setup Script/Outlook Exchange Setup 5.0.scpt</string>
</array>
<key>QueueDirectories</key>
<array>
<string>~/Library/Containers/com.microsoft.Outlook</string>
</array>
</dict>
</plist>


- Tried both with and without a trailing slash at the end of the QueueDirectories path
- Used the full path to the QueueDirectories path, e.g. /Users/username/Library/Containers/com.microsoft.Outlook/. This made the "UserEventAgent Ignoring path: ~/Library/Containers/com.microsoft.Outlook/" errors disappear
- Changed the ProgramArguments string to a shell script as per @Look's suggestion. The AppleScript still never ran. I added some code after the osascript line to write to a file and could confirm that part was working.



I checked the permissions on the LaunchAgent and made sure it was able to load correctly.



I even changed the .plist to just monitor a folder on the desktop (that didn't exist prior) and then run a script afterwards, all that worked. It just seems to not work when I have both the com.microsoft.Outlook folder and the AppleScript file configured :(



Does someone mind posting the contents of their LaunchAgent that I can test with?



EDIT: changed the QueueDirectories path to com.microsoft.Outlook as per mm2270's suggestion below


@mm2270 @plawrence I am also having issue getting this to work.