Solved

Export EmailAddresses

Posted on 2014-12-16
3
86 Views
Last Modified: 2015-01-31
I have  a list of user and would like to have their email addresses in following CSV format.

Displayname,EmailAddresses1,EmailAddress2..........

It similiar to:

http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/22/export-user-names-and-proxy-addresses-to-csv-file.aspx

I been tried to figure out but so far failed. What i got:

$Names = 'user1','user2'

Foreach ($u in $Names){

$email= (Get-Mailbox -Identity $u).emailaddresses | Select -ExpandProperty smtpaddress

#For ($i=0;$i -le $name.count;$i++){

$email = @{}
 
}#}

Open in new window

0
Comment
Question by:suriyaehnop
3 Comments
 
LVL 20

Accepted Solution

by:
Satya Pathak earned 250 total points
ID: 40504300
0
 
LVL 39

Assisted Solution

by:footech
footech earned 250 total points
ID: 40505681
One of the problems here is that the data doesn't fit well to a CSV format.  Each row could have a different number of columns depending on how many email addresses there are, and that also poses a problem for the headers.  For example:
Displayname,EmailAddresses1,EmailAddresses2
user1,a1@domain.com,a2@domain.com
user2,b1@domain.com,b2@domain.com,b2@domain.com,b3@domain.com,b4@domain.com

The headers are created based on the properties present in the first object passed to Export-CSV, so piping the above you would only get a file with "Displayname,EmailAddresses1,EmailAddresses2".  "EmailAddresses3,EmailAddresses4" would not get output for user2.

One way around this is to create a file that really is not a true .CSV.  It wouldn't have any headers, but each field would be separated by a comma.
Get-Mailbox | ForEach `
{
    Write-Output "$($_.DisplayName),$($_.EmailAddresses -join ",")"
} | Out-File output.txt -notype

Open in new window

0
 
LVL 18

Author Closing Comment

by:suriyaehnop
ID: 40581417
please close the question
0

Featured Post

Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Question has a verified solution.

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

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
A brief introduction to what I consider to be the best editor for PowerShell.
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

895 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

15 Experts available now in Live!

Get 1:1 Help Now