Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

add multiple secondary addresses to exchange accounts

Posted on 2013-12-20
5
Medium Priority
?
330 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 2000 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline

886 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