[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Exchange PowerShell:  Get all Primary SMTP Addresses of members of Distribution List

Posted on 2013-06-24
5
Medium Priority
?
3,181 Views
Last Modified: 2013-06-24
I have following script to export primary smtp addresses of a particular distribution list:

$HelloMailboxes = "HelloMailboxes"
$PathExportMailboxes = "C:\upload\HelloMailboxes.csv"


Get-DistributionGroupMember $HelloMailboxes  | Select PrimarySmtpAddress | Export-Csv $PathExportMailboxes -NoTypeInformation

Open in new window


The output of the command is:
"PrimarySmtpAddress"
"mary@haylock.ch"
"marie@haylock.ch"
"leandro@haylock.ch"
"buchhaltung@haylock.ch"
"bibliothek@haylock.ch"

Open in new window


I would like to have following output (without header and " characters):
mary@haylock.ch
marie@haylock.ch
leandro@haylock.ch
buchhaltung@haylock.ch
bibliothek@haylock.ch

Open in new window

0
Comment
Question by:whenz
[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
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39273033
Try..
Get-DistributionGroupMember $HelloMailboxes  | %{Add-Content C:\Group.txt $_.PrimarySmtpAddress.ToString()}

Open in new window

0
 

Author Closing Comment

by:whenz
ID: 39273041
Perfect as always!
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39273050
Another option..
Get-DistributionGroupMember $HelloMailboxes  | %{$_.PrimarySmtpAddress.ToString()} >C:\Group.txt 

Open in new window

0
 
LVL 4

Expert Comment

by:Dash Amr
ID: 39273058
This can be done from ADUC , where as you can create a query to get all the users and then from add and remove coloumn , you can add email address and then export the list to a csv file.

If you have the Saved query folder in teh Active Directory Users and computers Snap-in then you can do this:

1. Right-Click the folder and select New query
2. Give it a descriptive name
3. Click Define Query
4. From the drop down list select Custom Search
5. Clcik Advanced tab
6. Paste in the following:

(&(objectCategory=user)(memberOf=cn=Domain Admins,cn=users,dc=YourDomain,dc=local))

You will need to change the cn=..... part to suite your groups distinguished name.

then once you save this and get a list you can:
7. Right-click on your query
8. Select Export List (not Export Query definition as this just creates a backup of the query)
9. Select from the save as type:
   Text (Comma Delimited) (*.csv)
Which of course, opens in Excel as it is.

Cheers
Dash
0
 
LVL 4

Expert Comment

by:Dash Amr
ID: 39273085
Herein Attached a Script for o make it easier for you.

What does the script exactly do?

    1- Queries Active Directory for Contacts & Groups
    2- Lists their email addresses
    3- Queries Users
    4- Lists enabled users’ email addresses
    5- Lists disabled users’ email addresses separately (was required for a certain project I did a long time back)
    6- Outputs to command line and also to a text file – c:\proxyaddresses.txt
    - X.400 addresses are ignored
ListEmailAddresses.zip
0

Featured Post

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

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

One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
In this video we show how to create a mailbox database 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 >> Data…
Suggested Courses

650 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