Link to home
Start Free TrialLog in
Avatar of mawatson
mawatson

asked on

Adding Email Addresses to Multiple Mailboxes using Powershell

My goal is to add three email addresses to existing mail-enabled users in Exchange 2007 with Powershell.  Using the following as a guide, I can do one at a time:

$mbx = get-Mailbox "jdoe"; $mbx.EmailAddresses += "John.Doe@domain.com"; $mbx | Set-Mailbox

This is great for one-off mailboxes but I need to append 3 SMTP addresses to 640 mailboxes.  How can the above cmdlet be altered to take advantage of the ImportCSV cmdlet?  I'd like to pipe in the following CSV file if possible:

Alias,EmailAddress1,EmailAddress2,EmailAddress3
jdoe,john.doe@domain.com,john.doe@domain.ca,john.doe@nowhere.com

Any help is much appreciated!

Cheers...
Avatar of BiPod
BiPod
Flag of United Kingdom of Great Britain and Northern Ireland image

Would it not be easier to create an e-mail address policy here and apply it to the relevant users?
Avatar of mawatson
mawatson

ASKER

Ah...  I should've seen that question coming.  ;o)  Unfortunately, in the case of these mail users, we will not be applying Email Address Policies.
What I'd like to do is use the Set-Mailbox -EmailAddresses <ProxyAddressCollection> command to append new SMTP addresses to each of these mailboxes.  I'm not certain of the syntax.

I'm stuck pipelining the Get-Mailbox, Importcsv and Set-Mailbox cmdlets together.  I'm not sure how the Powershell command line should flow...
OK you want something along the lines of:


Import-CSV thecsvfile.csv | ForEach-Object -Process {Set-Mailbox -identity $_.Alias -EmaillAddressses "$_.EmailAddress1","$_.EmailAddress2","$_.EmailAddress3" }

Not 100% sre that will work as i've never tested it so give it a bash ona test box.  But something along those lines should work for you. It essentially takes the CSV file then ForEachObject loops round and processes the specified parameters.

Let us know if that helps!

Cheers,

BiPod
ASKER CERTIFIED SOLUTION
Avatar of mawatson
mawatson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial