Forum Discussion
Powershell for replacing primary email address and adding current primary to alias email addresses
- May 28, 2018
On-premises, you should be able to handle this via Email Address Policies: https://technet.microsoft.com/en-us/library/bb232171(v=exchg.150).aspx
It's also possible via PowerShell, the easiest example would be by using the -WindowsEmailAddress parameter:
Spoiler-WindowsEmailAddressThe WindowsEmailAddress parameter specifies the Windows email address for this recipient. This is a common Active Directory attribute that's present in all environments, including environments without Exchange. Using the WindowsEmailAddress parameter on a recipient has one of the following results:
-
In environments where the recipient is subject to email address policies (the EmailAddressPolicyEnabled property is set to the value True for the recipient), the WindowsEmailAddress parameter has no effect on the WindowsEmailAddress property or the primary email address value.
-
In environments where the recipient isn't subject to email address policies (the EmailAddressPolicyEnabled property is set to the value False for the recipient), the WindowsEmailAddress parameter updates the WindowsEmailAddress property and the primary email address to the same value.
The WindowsEmailAddress property is visible for the recipient in Active Directory Users and Computers in the E-mail attribute. The attribute common name is E-mail-Addresses, and the Ldap-Display-Name is mail. If you modify this attribute in Active Directory, the recipient's primary email address is not updated to the same value.
Doing so will add the new primary SMTP address, while preserving the old one as secondary. Alternatively you can cook up a more complex function to check out each individual address and add/remove new ones as needed. I have some examples on how to do this here:
https://www.michev.info/Blog/Post/2011/bulk-replacing-proxy-addresses-based-on-a-pattern
-
On-premises, you should be able to handle this via Email Address Policies: https://technet.microsoft.com/en-us/library/bb232171(v=exchg.150).aspx
It's also possible via PowerShell, the easiest example would be by using the -WindowsEmailAddress parameter:
The WindowsEmailAddress parameter specifies the Windows email address for this recipient. This is a common Active Directory attribute that's present in all environments, including environments without Exchange. Using the WindowsEmailAddress parameter on a recipient has one of the following results:
-
In environments where the recipient is subject to email address policies (the EmailAddressPolicyEnabled property is set to the value True for the recipient), the WindowsEmailAddress parameter has no effect on the WindowsEmailAddress property or the primary email address value.
-
In environments where the recipient isn't subject to email address policies (the EmailAddressPolicyEnabled property is set to the value False for the recipient), the WindowsEmailAddress parameter updates the WindowsEmailAddress property and the primary email address to the same value.
The WindowsEmailAddress property is visible for the recipient in Active Directory Users and Computers in the E-mail attribute. The attribute common name is E-mail-Addresses, and the Ldap-Display-Name is mail. If you modify this attribute in Active Directory, the recipient's primary email address is not updated to the same value.
Doing so will add the new primary SMTP address, while preserving the old one as secondary. Alternatively you can cook up a more complex function to check out each individual address and add/remove new ones as needed. I have some examples on how to do this here:
https://www.michev.info/Blog/Post/2011/bulk-replacing-proxy-addresses-based-on-a-pattern
What a great, thorough response. Thank you for your assistance.
April