This article will demonstrate how to manage proxy addresses in Active Directory and define what exactly the proxyAddresses AD attribute is.
The proxyAddresses attribute is multivalued and is used on users, groups, and contacts in Active Directory to facilitate email delivery.
The following table describes the semantics for the prefix usage of the proxy addresses.
Prefix | Description |
SMTP | The primary (sending) email address |
smtp | Secondary email addresses. Also known as aliases. |
Note that duplicate addresses are not allowed across your entire Active Directory. Take caution when modifying this attribute as you can break email for the object being modified.
If you are trying to modify an O365 email alias in the O365 admin portal and you have a local authoritative AD, you may see the following message.
This user is synchronized with your local Active Directory. Some details can be edited only through your local Active Directory.
Follow the instructions below to modify the O365 mail alias and perform an AD Connect sync at the end.
Proxy Addresses Active Directory with PowerShell
The proxyAddresses attribute can be modified with Active Directory Users and Computers, but this article will demonstrate how to manage it with PowerShell. Note that if you are not on a domain joined computer, you will have to provide the credential as part of the command. The culminating script provided below will do just that.
These examples assume that the ActiveDirectory PowerShell module is installed.
Import-Module ActiveDirectory
Follow these steps to manage proxy addresses for a user object.
Get AD User with PowerShell
Use the Get-ADUser command to retrieve the user being modified. Make sure to include the proxyAddresses attribute in your retrieval.
$user = Get-ADUser <samAccountName> -Properties proxyAddresses -Credential <credential>
Add a proxy address using PowerShell
Using the $user object above, add a proxy address. This example is adding a new secondary or alias email address.
$user.proxyAddresses.Add("smtp:<new-proxy-address>")
Remove a proxy address using PowerShell
$user.proxyAddresses.Remove("smtp:<new-proxy-address>")
Save the proxy address attribute
Use the Set-ADUser command with the same $user object to save the updates to the proxyAddresses attribute.
Set-ADuser -instance $user
Display the proxyAddresses attribute
Now that you have made changes to the proxyAddresses attribute, display them to verify the change was successful.
Get-ADuser <samAccountName> -Properties proxyAddresses -Credential <credential>
The output should display the proxyAddresses attribute and look similar to the following.
proxyAddresses : {smtp:secondary@example.com, SMTP:primary@example.com,
smtp:third@example.com}
Take note that only one SMTP (in all caps) is allowed as it is the primary.
To print each proxy address separately you can write a short PowerShell script to do so.
$credential = Get-Credential ""
$samAccountName = Read-Host -Prompt "Enter samAccountName"
$User = Get-ADUser -Identity $samAccountName -Properties proxyAddresses -Credential $credential
ForEach ($proxyAddress in $User.proxyAddresses) {
$Output = $Object.distinguishedName + ";" + $proxyAddress
Write-Host $Output
}
Use this convenience script to auto prompt for the required values needed to update proxy addresses.
Sync proxyAddresses change with Azure
After modifying the proxyAddresses attribute for a user you may want to immediately sync with Azure. We documented how to do so in this article. This is useful when modifying O365 mailbox aliases. If you do not need to immediately sync you can wait on your regularly schedule AD Connect sync to run, which is usually on a 30 minute interval.
Conclusion – Proxy Addresses Active Directory
This article has demonstrated how to add, remove, and query the active directory proxy addresses attribute. Let us know in the comments if you have any questions or would like to see further examples on modifying the proxyAddresses Active Directory attribute. If you found this article helpful, please read more of our PowerShell content.
Leave a Reply