Managing Recipient Addresses using CPolydorou.Exchange

Managing the a recipient's addresses can be a time consuming process since it involves the multi value Active Directory attribute "proxyAddresses". This can be tricky when using PowerShell, especially for the less experienced administrator.

Since I have also wasted a lot of time on this, I decided to make things easier and write a few functions to update the proxy addresses of objects.

Getting
To get the proxy addresses of an object, simply use the Get-RecipientAddress function with the identity of the recipient.

[PS] C:\>Get-RecipientAddress -Identity cpolydorou@lab.com

Identity                               Type Address              Primary
--------                               ---- -------              -------
LAB.local/LAB/Users/Christos Polydorou sip  cpolydorou@lab.local
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou@lab.local False
LAB.local/LAB/Users/Christos Polydorou SMTP cpolydorou@lab.com   True

[PS] C:\>

Adding
The New-RecipientAddress cmdlet will add a proxy address to an object:

[PS] C:\> New-RecipientAddress -Identity cpolydorou@lab.com `
                               -Type SMTP `
                               -Address cpolydorou2@lab.local `
                               -Confirm:$false
[PS] C:\>Get-RecipientAddress -Identity cpolydorou@lab.com

Identity                               Type Address               Primary
--------                               ---- -------               -------
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou2@lab.local False
LAB.local/LAB/Users/Christos Polydorou sip  cpolydorou@lab.local
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou@lab.local  False
LAB.local/LAB/Users/Christos Polydorou SMTP cpolydorou@lab.com    True

[PS] C:\>

The "-Primary" switch will add the address as the primary one:

[PS] [PS] C:\>New-RecipientAddress -Identity cpolydorou@lab.com `
                                   -Type SMTP `
                                   -Address cpolydorou3@lab.local `
                                   -Primary `
                                   -Confirm:$ false
[PS] C:\>Get-RecipientAddress -Identity cpolydorou@lab.com

Identity                               Type Address               Primary
--------                               ---- -------               -------
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou@lab.com    False
LAB.local/LAB/Users/Christos Polydorou SMTP cpolydorou3@lab.local True
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou2@lab.local False
LAB.local/LAB/Users/Christos Polydorou sip  cpolydorou@lab.local
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou@lab.local  False

[PS] C:\>

Removing
Removing a proxy address is a lot easier using the Remove-RecipientAddress. This function will remove a proxy address from an object (removing the cpolydorou2@lab.local address):

[PS] C:\>Remove-RecipientAddress -Identity cpolydorou@lab.com `
                                 -Address cpolydorou2@lab.local `
                                 -Type SMTP `
                                 -Confirm:$false
[PS] C:\>Get-RecipientAddress -Identity cpolydorou@lab.com

Identity                               Type Address               Primary
--------                               ---- -------               -------
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou@lab.com    False
LAB.local/LAB/Users/Christos Polydorou SMTP cpolydorou3@lab.local True
LAB.local/LAB/Users/Christos Polydorou sip  cpolydorou@lab.local
LAB.local/LAB/Users/Christos Polydorou smtp cpolydorou@lab.local  False

[PS] C:\>

The above functions update the proxyAddresses field on Active Directory, thus some time may be required in order for the change to be visible and take effect.

The above functions are included in my Exchange module that is published on PowerShell Gallery.

Have fun!

Popular posts from this blog

Domain Controller Machine Password Reset

Configuring a Certificate on Exchange Receive Connector

Running Multiple NGINX Ingress Controllers in AKS