Posted on 08-13-2014 10:51 AM
Hope you're doing well!
Pardon the intrusion for including you directly on this discussion from the get go…wondering if you can help or point me on the right direction with the following:
Our Outlook account profiles are currently setup using an e-mail address format = jsmith@testco.com (1st initial + last name)
We will soon be changing users e-mail addresses with the first name.last name format, john.smith@testco.com.
what would be the best non-manual process to change the Outlook account profile information on the E-mail address field…
From:
jsmith@testco.com
To:
john.smith@testco.com
Thank you for your input.
If anyone else has gone through the same process and has implemented a solution, I would too appreciate your input.
Thank you.
Solved! Go to Solution.
Posted on 08-16-2014 07:52 AM
@lsmc08][/url, just now seeing your message.
You probably won't be able to make this transition completely automated but you can take advantage of Casper to make this easier for your users.
First, Outlook for Mac only recognizes AppleScript. Account information is not stored in .plist files, so you can't run shell scripts using "defaults" to change anything.
Second, carefully test whatever solution you put into place. I know that changing the username or domain for an account will completely flush all cached data and force a new download. That can be a strain on your server if everyone cuts over the same morning of the same day. I'm not sure if changing the email address will do this too, but I don't think it will.
I suggest using an AppleScript in Self Service to help users change their email addresses. Let's assume you change a user's address in Exchange and then the user launches Outlook for Mac. He'll probably receive an authentication error message. He can then go to Self Service and click a "Fix my Outlook" button. That button would do a quick Active Directory lookup of his account (assuming his Mac is bound to AD) and retrieve the correct email address. It can then change the address in Outlook. Just a couple of seconds.
Here's a rough untested AppleScript:
-- get the currently logged in user's short name
tell application "System Events"
set UserName to name of (current user)
end tell
-- read the currently logged in user's email address from Active Directory
-- be sure to update the NETBIOS domain name in the next line
set ADLookup to "dscl '/Active Directory/TALKINGMOOSE/All Domains' -read '/Users/" & UserName & " EMailAddress | awk '{print $2}'" as string
set newEmailAddress to do shell script ADLookup
-- change the email address for the current user's Exchange account
tell application "Microsoft Outlook"
try
set email address of exchange account 1 to newEmailAddress
-- it worked
display dialog "Your Outlook settings have been corrected. Please re-enter your password when prompted." with icon 1 with title "Correct Outlook Settings" buttons {"OK"} default button {"OK"}
on error
-- it failed
display dialog "Your Outlook settings could not be corrected. Please contact the Help Desk at (612) 555-1212." with icon stop with title "Correct Outlook Settings" buttons {"OK"}
end try
end tell
The most important part of any major change like this is communication with your users before this happens. Let them know what will happen, let them know when it's happening and tell them what just happened.
Posted on 09-12-2014 03:23 PM
Thank you for your direction and help on this one.
We were able to accomplish this successfully - below I'll post the working version of the script.
I did not implemented through SS. I dropped it via a policy in the Outlook script folder. Be aware that if you have 10.6.x systems, this path is different from what would be for 10.9.x-10.7.x.
Thanks and have a great weekend!
Below is the script for those who might need it:
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
----- This is to change currently logged in user's Exchange account to --------
----- new UPN change in Active Directory --------
----- --------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
-- get the currently logged in user's short name
tell application "System Events"
set UserName to name of (current user)
end tell
-- read the currently logged in user's email address from Active Directory
-- be sure to update the NETBIOS domain name in the next line
set ADLookup to do shell script "dscl "/Active Directory/DOMAIN_NAME_HERE/All Domains/" -read /Users/" & UserName & " dsAttrTypeNative:userPrincipalName | awk '{print $2}'" as string
set newEmailAddress to ADLookup
-- change the email address for the current user's Exchange account
tell application "Microsoft Outlook"
try set background autodiscover of exchange account 1 to true set email address of exchange account 1 to newEmailAddress
-- it worked
display dialog "Your Outlook settings have been corrected. Please re-enter your password when prompted." with icon 1 with title "Correct Outlook Settings" buttons {"OK"} default button {"OK"} on error
-- it failed
display dialog "Your Outlook settings could not be corrected. Please contact the Help Desk at (XXX) XXX-XXXX.” with icon stop with title "Correct Outlook Settings" buttons {"OK"}
end try
end tell
Posted on 08-13-2014 01:22 PM
We faced a similar issue a while back. A problem like this certainly has a lot of variables so everyones approach may be slightly different and mileage may vary. The way we handled it was using the scripts at http://www.officeformachelp.com/outlook/exchange/setup-script/ .
We created a policy triggered at login to run once per user for a script to remove the existing account and run the setup script. Which prompts the users to verify there email address (we do that in case a user has a nonstandard syntax email address) but the verification part is optional and the setup script gives an option to enable or disable.
Posted on 08-16-2014 07:52 AM
@lsmc08][/url, just now seeing your message.
You probably won't be able to make this transition completely automated but you can take advantage of Casper to make this easier for your users.
First, Outlook for Mac only recognizes AppleScript. Account information is not stored in .plist files, so you can't run shell scripts using "defaults" to change anything.
Second, carefully test whatever solution you put into place. I know that changing the username or domain for an account will completely flush all cached data and force a new download. That can be a strain on your server if everyone cuts over the same morning of the same day. I'm not sure if changing the email address will do this too, but I don't think it will.
I suggest using an AppleScript in Self Service to help users change their email addresses. Let's assume you change a user's address in Exchange and then the user launches Outlook for Mac. He'll probably receive an authentication error message. He can then go to Self Service and click a "Fix my Outlook" button. That button would do a quick Active Directory lookup of his account (assuming his Mac is bound to AD) and retrieve the correct email address. It can then change the address in Outlook. Just a couple of seconds.
Here's a rough untested AppleScript:
-- get the currently logged in user's short name
tell application "System Events"
set UserName to name of (current user)
end tell
-- read the currently logged in user's email address from Active Directory
-- be sure to update the NETBIOS domain name in the next line
set ADLookup to "dscl '/Active Directory/TALKINGMOOSE/All Domains' -read '/Users/" & UserName & " EMailAddress | awk '{print $2}'" as string
set newEmailAddress to do shell script ADLookup
-- change the email address for the current user's Exchange account
tell application "Microsoft Outlook"
try
set email address of exchange account 1 to newEmailAddress
-- it worked
display dialog "Your Outlook settings have been corrected. Please re-enter your password when prompted." with icon 1 with title "Correct Outlook Settings" buttons {"OK"} default button {"OK"}
on error
-- it failed
display dialog "Your Outlook settings could not be corrected. Please contact the Help Desk at (612) 555-1212." with icon stop with title "Correct Outlook Settings" buttons {"OK"}
end try
end tell
The most important part of any major change like this is communication with your users before this happens. Let them know what will happen, let them know when it's happening and tell them what just happened.
Posted on 08-18-2014 09:27 AM
Thank you for your response and suggestion.
I was considering the approach of removing the account too, however, for some users that would be very painful as it would take a very long time for all the Exchange items and folders to update within that new Outlook account.
So without removing the Outlook account, we only need to change the e-mail address portion since that's the only thing changing.
Again, thank you for your input.
Posted on 08-18-2014 09:31 AM
No worries and thank you for your reply here.
I will edit your script accordingly with our domain here and other applicable stuff and then test away.
I will report my findings as soon as my testing is done.
Thanks again for your collaboration!
Posted on 09-12-2014 03:23 PM
Thank you for your direction and help on this one.
We were able to accomplish this successfully - below I'll post the working version of the script.
I did not implemented through SS. I dropped it via a policy in the Outlook script folder. Be aware that if you have 10.6.x systems, this path is different from what would be for 10.9.x-10.7.x.
Thanks and have a great weekend!
Below is the script for those who might need it:
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
----- This is to change currently logged in user's Exchange account to --------
----- new UPN change in Active Directory --------
----- --------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
-- get the currently logged in user's short name
tell application "System Events"
set UserName to name of (current user)
end tell
-- read the currently logged in user's email address from Active Directory
-- be sure to update the NETBIOS domain name in the next line
set ADLookup to do shell script "dscl "/Active Directory/DOMAIN_NAME_HERE/All Domains/" -read /Users/" & UserName & " dsAttrTypeNative:userPrincipalName | awk '{print $2}'" as string
set newEmailAddress to ADLookup
-- change the email address for the current user's Exchange account
tell application "Microsoft Outlook"
try set background autodiscover of exchange account 1 to true set email address of exchange account 1 to newEmailAddress
-- it worked
display dialog "Your Outlook settings have been corrected. Please re-enter your password when prompted." with icon 1 with title "Correct Outlook Settings" buttons {"OK"} default button {"OK"} on error
-- it failed
display dialog "Your Outlook settings could not be corrected. Please contact the Help Desk at (XXX) XXX-XXXX.” with icon stop with title "Correct Outlook Settings" buttons {"OK"}
end try
end tell
Posted on 09-14-2014 09:01 AM
Glad to hear you've got a solution! I think adding the background autodiscover setting was a good idea.
Posted on 03-11-2016 03:36 PM
I'm looking to change the username field in Outlook 2016 and I came across your great work on this. What I have is an AppleScript (based on your work) embedded in a shell script but instead of returning the UPN (user@acmeco.com), its returning the following, basically the attribute name followed by the UPN. any idea of what might be happening here?
what it should return (and does in AppleScript): user@acmeco.com
what its returning once I embed the AppleScript: dsAttrTypeNative:userPrincipalName: user@acmeco.com
Script:
!/bin/sh
osascript <<-EOF
tell application "System Events"
set UserName to name of (current user)
end tell
set ADLookup to do shell script "dscl "/Active Directory/ACMECO/All Domains/" -read /Users/" & UserName & " dsAttrTypeNative:userPrincipalName | awk '{print $2}'" as string
display dialog ADLookup
EOF
Posted on 03-11-2016 09:17 PM
@mapurcel, looks like you've got a shell script embedded in an AppleScript in another shell script. It's like a turduckturk™ of scripting!
Try doing this with just a shell script. Something like this:
dscl "/Active Directory/ACMECO/All Domains" -read /Users/$USER dsAttrTypeNative:userPrincipalName | awk '{print $2}'
Posted on 03-14-2016 03:22 PM
:) good call, I ended up with the following. thanks for the help
#!/bin/bash
User=`stat -f "%Su" /dev/console`
upn=`dscl "/Active Directory/ACMECO/All Domains" -read /Users/$User dsAttrTypeNative:userPrincipalName | awk '{print $2}'`
osascript 2> /dev/null <<-EOF
tell application "Microsoft Outlook"
set domain of every exchange account to ""
end tell
tell application "Microsoft Outlook"
set user name of every exchange account to "$upn"
end tell
EOF
Posted on 06-04-2020 09:54 AM
@talkingmoose Can you please help with the script to copy the username field in outlook to email address field ?
Posted on 06-04-2020 01:08 PM
@gsabari, also responded to you on Slack.
I have a script for Self Service to do this. I recommend instructing the user to click a button in Self Service to run the policy because it requires Microsoft Outlook be running.
https://gist.github.com/talkingmoose/d96d5885c38b6228e1999861b7be0839