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,EmailA ddress2,Em ailAddress 3
jdoe,john.doe@domain.com,j ohn.doe@do main.ca,jo hn.doe@now here.com
Any help is much appreciated!
Cheers...
$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,EmailA
jdoe,john.doe@domain.com,j
Any help is much appreciated!
Cheers...
Would it not be easier to create an e-mail address policy here and apply it to the relevant users?
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.
ASKER
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...
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","$_.Ema ilAddress2 ","$_.Emai lAddress3" }
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
Import-CSV thecsvfile.csv | ForEach-Object -Process {Set-Mailbox -identity $_.Alias -EmaillAddressses "$_.EmailAddress1","$_.Ema
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.