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
Solved

Export EmailAddresses

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

Author Closing Comment

by:suriyaehnop
ID: 40581417
please close the question
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A brief introduction to what I consider to be the best editor for PowerShell.
In this video we show how to create a Contact 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 >> Contact ta…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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