Posted on 01-14-2022 04:46 AM
Hey there,
we're trying to set some advanced settings in Microsoft Outlook. We want to tick the red outlined box and enable SSL.
Right now we're using this script, which work's, but throws an error. I'm not really into scripting but i tried a little bit on my own and came out with the following:
osascript <<END
tell application "Microsoft Outlook"
set ldap server of exchange account 1 to "XXX"
set ldap use ssl of exchange account 1 to yes
set ldap port of exchange account 1 to 6666
end tell
END
It throws no error, but it won't enable SSL either. I think it's because I don't define the default exchange account and I don't really know how to do it. Shouldn't it be just "exchange account 1"? I tried many things out but I can't get it to work...
Thanks for any help!
Solved! Go to Solution.
Posted on 05-25-2022 02:38 AM
Alright. I got it. :)
#!/bin/sh
#Get current User
currentuser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
echo $currentuser
#Runs Apple Script with current User
sudo -u $currentuser /usr/bin/osascript -e 'tell application "Microsoft Outlook" to set properties of exchange account 1 to {ldap server:"XXX", ldap use ssl:true, ldap port:"3269"}'
Posted on 01-14-2022 07:12 AM
Hi, please remember in Jamf it runs any policy as root not as a user so to get a script to run as a user do this:
# Get current logged in user
curUser="`stat -f%Su /dev/console`"
#Run script as user
sudo -u $curUser osascript <<'END' tell application "Microsoft Outlook" set exList to get every exchange account repeat with exItem in exList set exDomain to get server of exItem if exDomain is "https://OurServer.org/EWS/Exchange.asmx" then set ldap server of exItem to "ldap.OurServer.org" set ldap port of exItem to 3269 set ldap use ssl of exItem to true end if end repeat end tell END
Posted on 01-14-2022 07:38 AM
Yes, you're right, but somehow this is working without running it as user. It enables SSL but still throws the following error:
Script result: 252:306: execution error: Microsoft Outlook got an error: The user name of the account is required. (-1715)
Posted on 01-14-2022 07:59 AM
I just tested this script and it worked for me. How are you testing this?
01-14-2022 08:05 AM - edited 01-14-2022 08:06 AM
I run it like this:
#!/bin/bash
# Get current logged in user
curUser="`stat -f%Su /dev/console`"
# Run script as user
sudo -u $curUser osascript <<'END'
tell application "Microsoft Outlook"
set exList to get every exchange account
repeat with exItem in exList
set exDomain to get server of exItem
if exDomain is "Server" then
set ldap server of exItem to "Server"
set ldap port of exItem to 3269
set ldap use ssl of exItem to true
end if
end repeat
end tell
END
Posted on 01-14-2022 08:07 AM
Sorry, let me clarify. I meant how are you testing this script? Are you running locally to test or in Jamf?
Posted on 01-14-2022 08:09 AM
Ah, I use a policy, available in self service, which calls the script
Posted on 01-14-2022 08:15 AM
Is an Outlook profile already existing when you tested this?
Posted on 01-17-2022 12:02 AM
Yes, there is an active profile when testing.
Posted on 02-09-2022 02:22 AM
Push
Posted on 05-25-2022 02:38 AM
Alright. I got it. :)
#!/bin/sh
#Get current User
currentuser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
echo $currentuser
#Runs Apple Script with current User
sudo -u $currentuser /usr/bin/osascript -e 'tell application "Microsoft Outlook" to set properties of exchange account 1 to {ldap server:"XXX", ldap use ssl:true, ldap port:"3269"}'
Posted on 09-06-2022 03:40 AM
@Tim_Apple How do you configured the outlook account? Do you authenticate with name and password or Kerberos? I cant get it work when I have an account that is configured with Kerberos,