Solved

Exchange PowerShell:  List SMTP E-Mail address from a Distribution List in a defined format

Posted on 2013-06-24
4
582 Views
Last Modified: 2013-06-24
I need to extract following information from a Distribution List:

 - Primary SMTP Address of ManagedBy object
 - All SMTP addresses of all members of the distribution list


then I need to have the following format of the output

--------------------------------------------------------output.txt--------------------------------------------------------
SMTPAddress1Member1 PrimarySMTPAddressOfManagedByObject
SMTPAddress2Member1 PrimarySMTPAddressOfManagedByObject
SMTPAddress3Member1 PrimarySMTPAddressOfManagedByObject
SMTPAddress1Member2 PrimarySMTPAddressOfManagedByObject
SMTPAddress2Member2 PrimarySMTPAddressOfManagedByObject
--------------------------------------------------------output.txt--------------------------------------------------------

Example output.txt file:

Mark.Henderson@gmail.com JunkAdmin1@gmail.com
M.Henderson@gmail.com JunkAdmin1@gmail.com
Mark.H@gmail.com JunkAdmin1@gmail.com
Lisa.Simpson@gmail.com  JunkAdmin1@gmail.com
L.Simpson@gmail.com  JunkAdmin1@gmail.com
Lisa.S@gmail.com  JunkAdmin1@gmail.com
Michael.Kight@gmail.com  JunkAdmin1@gmail.com
M.Kight@gmail.com  JunkAdmin1@gmail.com
Michael.K@gmail.com  JunkAdmin1@gmail.com

Open in new window



I know this sounds very tricky, but maybe someone coded this one already :-)

Thanks for any help!
0
Comment
Question by:whenz
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39272670
By PrimarySMTPAddressOfManagedByObject, do you mean the PrimarySMTPAddress of the group?
0
 

Author Comment

by:whenz
ID: 39272690
No, I mean the primary SMTP Address of the ManagedBy Attribute.  Please see the attached example, I would need the primary SMTP address of user "povici"
EE-screenshot.jpg
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39272736
Try..
$Group = "Group Name"
$ManagedBy = (Get-Mailbox (Get-DistributionGroup "Group Name").ManagedBy).PrimarySmtpAddress.ToString()

Get-DistributionGroupMember $Group | % {

Add-Content C:\Group.txt "$($_.PrimarySmtpAddress.ToString()) $ManagedBy"

}

Open in new window

0
 

Author Closing Comment

by:whenz
ID: 39272824
Subsun you're a wizard, thank you indeed!!!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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 …
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…

830 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