Appending to a list of proxyAddresses in Exchange Management Shell

Jason CrawfordTransport Ninja
CERTIFIED EXPERT
(FYDIBOHF24SPDLT)
Published:
Updated:
Utilizing an array to gracefully append to a list of EmailAddresses
Adding to a list of EmailAddresses in Exchange has the potential to be one of those 'gotcha' issues that, if performed incorrectly, can really make you momentarily rethink your career in IT.  This is because if proper measures are not taken, the list of mailbox alias' can be overwritten by your one addition.  For example, if the following command was run, all pre-existing proxyAddresses would be overwritten with the addition of userA1@domain.com:
 
Set-Mailbox userA -EmailAddresses 'userA1@domain.com'

Open in new window


The process to work around this has traditionally involved adding the complete list of alias' each time instead of just the one like so:
 
$user = Get-Mailbox userA
                      $user.EmailAddresses += 'userA1@domain.com'
                      $user | Set-Mailbox

Open in new window


A simple work around available in PowerShell 2.0 and beyond involves the use of an array:
 
Set-Mailbox userA -EmailAddresses @{add='userA1@domain.com'}

Open in new window


Now we can add just one address at a time instead of being forced to account for the entire list with each new request.  Enjoy!
0
3,436 Views
Jason CrawfordTransport Ninja
CERTIFIED EXPERT
(FYDIBOHF24SPDLT)

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.