Solved

Export EmailAddresses

Posted on 2014-12-16
3
83 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:
SatyaPathak 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create a Distribution Group 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 Recipients >>…
This video discusses moving either the default database or any database to a new volume.

757 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