Solved

add multiple secondary addresses to exchange accounts

Posted on 2013-12-20
5
310 Views
Last Modified: 2013-12-20
I have a list of user accounts that need secondary acounts from an exchange list.



user1  user1@somecompany.com
user2  user2@contoso.local
user3  user4@yahoo.com

I was going to try somthing like this but it does not work pleae help

import-csv c:\temp\addusers.csv | foreach-object {set-mailbox $_ -emailaddress
0
Comment
Question by:techdrive
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 39732373
Import-Csv c:\temp\addusers.csv | Foreach-Object{
$user = Get-Mailbox -Identity $_.LoginName
$user.EmailAddresses+=$_.SecondaryAddress
Set-Mailbox $user -EmailAddresses $user.EmailAddresses
}

This is based on the idea of creating the csv with Login Name and secondary email in the csv.
0
 

Author Comment

by:techdrive
ID: 39732407
this is going through the entire directory. I do not think this is correct
0
 
LVL 29

Expert Comment

by:becraig
ID: 39732432
I assume you are talking about the line:
$user = Get-Mailbox -Identity $_.LoginName

Which simply identifies the user mailbox that matches the value from your csv LoginName.

I am not sure how you would want to update the user without validating from the directory that the mailbox you want to update exists in the directory  ?

I would suspect in order to update the mailbox you would need to identify the user to update which is what this line does.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39732455
Try..
Import-CSV C:\temp\users.CSV | % {
Set-Mailbox $_.UserName -EmailAddresses @{add=$_.Email}
}

Open in new window

Sample Csv file..
UserName,Email
user1,user1@somecompany.com
user2,user2@contoso.local
user3,user4@yahoo.com

Open in new window

0
 

Author Comment

by:techdrive
ID: 39732499
Subsun many many thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question