Solved

Export EmailAddresses

Posted on 2014-12-16
3
92 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

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

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 19

Author Closing Comment

by:suriyaehnop
ID: 40581417
please close the question
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

This article explains how to install and use the NTBackup utility that comes with Windows Server.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In this video we show how to create an Accepted Domain 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 >> Ac…
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 antispam), the admini…

730 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