Solved

add multiple secondary addresses to exchange accounts

Posted on 2013-12-20
5
306 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A brief introduction to what I consider to be the best editor for PowerShell.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now