Solved

Export EmailAddresses

Posted on 2014-12-16
3
97 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
To show how to generate a certificate request 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 Servers >> Certificates…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

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