Solved

add multiple secondary addresses to exchange accounts

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

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 28

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

19 Experts available now in Live!

Get 1:1 Help Now