I recently had the opportunity to give a presentation on the Idera PowerShell Power Hour Webcast. The topic was Exchange Enterprise Management with PowerShell, and I was excited to be able to answer so many great questions during the Q and A portion of the webcast. One request for help required a more lengthy explanation that I couldn’t provide via web chat, and that’s the reason for this post. If you’ve ever wanted to add one or more proxy address to a list of mailboxes from a CSV file, the solution provided here is for you.

First let me say that adding proxy addresses to multiple recipients can be done even easier with E-Mail Address Policies. You can read all about them here. However, if you are determined to get this done using PowerShell, it’s actually pretty simple to do. I am going to assume you are at least running Exchange 2010 SP1, and that will allow us to utilize this cool hash table trick that can be used to add and remove values from multivalued properties.

Let’s say that you have a CSV file setup like the following:

The Name column shown above contains aliases for existing mailbox-enabled users. The ProxyAddresses column contains a semi-colon separated list of addresses that need to be added to each associated mailbox. The key to making this work is converting the ProxyAddresses value into a collection of addresses. We can use the Import-CSV cmdlet to read our source file, and for each record, we’ll process the list of ProxyAddresses by adding them to each corresponding mailbox. Let’s start first with a simple example:

PS C:\> Import-Csv C:\AddressList.csv | ForEach-Object{$_.ProxyAddresses -split ';'}

Notice that as we loop through each record, we take the value assigned to the ProxyAddresses column and split it into an array using the PowerShell v2 split operator. When we split this value, we can simply iterate over each item returned and the add proxy addresses to the mailbox. Here’s our final code sample that will get this job done:

Import-Csv C:\AddressList.csv | ForEach-Object{
  $name = $_.Name
  $proxy = $_.ProxyAddresses -split ';'
  Set-Mailbox -Identity $name -EmailAddresses @{add= $proxy}

The -EmailAddresses parameter is available for cmdlets that modify other recipient types. If needed, replace the call to Set-Mailbox with Set-MailUser, Set-MailContact, etc. and use the same kind of syntax to add proxy addresses.