|
Replies:
1
-
Pages:
1
-
Last Post:
Dec 3, 2009 1:44 PM
by: Shay Levy
|
|
|
Posts:
1
Registered:
12/3/09
|
|
|
|
add emails from csv
Posted:
Dec 3, 2009 11:34 AM
|
|
|
Hi I am trying to add email aliases in exchange 2007 from a csv file
The csv file I have looks like this: displayName,mail,proxyAddress,ProxyAddress2,proxyAddress3
What I would like to do is:
For each displayname add mail as primary address if listed add proxyaddress if listed add proxyaddress2 if listed add proxyaddress3
Thanks
|
|
|
Posts:
1,919
Registered:
1/31/08
|
|
|
|
Re: add emails from csv
Posted:
Dec 3, 2009 1:44 PM
in response to: jk2ny
|
|
|
I didn't test but this should work:
import-csv users.csv | foreach { $mailbox = get-mailbox $_displayName $emails = $_ | foreach {$_.proxyaddress,$_.proxyaddress2,$_.proxyaddress3} | where {$_} if($emails) { $mailbox.emailAddresses+=$emails set-mailbox $mailbox -emailAddresses $emails } set-mailbox $mailbox -primaryEmailAddress $_.email }
|
Shay Levy [MVP]
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar
|
|
|
Legend
|
|
MVP: 2501
+
pts
|
|
Guru: 2001
- 2500
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|