• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 854
  • Last Modified:

Export Exchange 2007 Distribution Group and All Associate SMTP Addresses to CSV

I am trying to find a way to pull a list of all my Distribution Groups, and all their assoicate SMTP addresses and export them to .csv.  I have found a couple of powershell scripts that get me close, however I haven't gotten there completely.  Does anyone have any suggestions?
0
malarkie
Asked:
malarkie
  • 6
  • 6
  • 3
1 Solution
 
JohnGrunwellCommented:
power shell command should pull all the information for each member in the group

Get-DistributionGroupMember "<Group Name>" | Export-CSV -Path "<FileName>"

0
 
JohnGrunwellCommented:
if you want all groups with certain fields like display name and smtp only you can use this in powershell

Get-DistributionGroup | %{
  $Group = $_
  $Group | Get-DistributionGroupMember |
    Select-Object @{n='GroupName';e={ $Group.Name }}, DisplayName, PrimarySMTPaddress
} | Export-CSV "filename location"

0
 
AkhaterCommented:
here you go
$gprs = Get-DistributionGroup -ResultSize unlimited

$grps | %{$n = $_.name; Get-DistributionGroupMember $_} | Select-Object name,@{label="Group";expression={$n}} | export-csv c:\list.csv

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
JohnGrunwellCommented:
To view the specific field names that you might want for exchange users
get-mailbox -identity "<domain\username>"  | fl
0
 
malarkieAuthor Commented:
John & Akhater,
I tried your suggestions, howeve the resultant set only gives me Distro list and Members email addresses.  I need to get the Distro lists, as well as the Distro lists associated email addresses.  So for example, I have a Support Distro list that when someone emails either support@xyz.com or supportIT@xyz.com or help@xyz.com, when I run this powershell script it should give me;
Support, Support@xyz.com, SupportIT@xyz.com, help@xyz.com.  I found the following, however I want it to export it rather than write it to the screen, however my lack of understanding of coding leaves me drawing a blank.
Get-DistributionGroup | select name , alias ,EmailAddresses | foreach {
   “Name: “+$_.name
   “Alias: “+$_.alias
    $_.EmailAddresses | foreach {
      if($_.SmtpAddress){
      “SmtpAddress: “+$_.SmtpAddress
    }
 }
 write-host
 }

Open in new window

0
 
AkhaterCommented:
You lost me, you wanted to groups members now you are looking for the aliases of the groups?

Get-DistributionGroup -resultSize unlimited | select name -expand emailAddresses | where {$_.smtpAddress} | Export-Csv c:\t.txt
0
 
malarkieAuthor Commented:
I don't believe I ever said I needed the group members, but it is an added benefit I received from this post.  I have saved all of these scripts as I can definitely see the benefit of what you all have posted so far.  But yes, the aliases of the group.  
The script you gave me doesn't return all the aliases for each group, just the first.  

Thanks again, I do appreciate your help.
0
 
AkhaterCommented:
sorry i dont know why i thoght u asked for the members :)

Use your script just add at the end > c:\t.txt
0
 
AkhaterCommented:
and sorry my script doesn't export only the first alias it exports them , check the csv you will see multiple entries for the same group each one for an smtp address
0
 
malarkieAuthor Commented:
Getting closer.  I put that right after the "Write Host" and I get a blank document.  If I take out the "Write Host", I get

The term '>' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included,
 verify that the path is correct and try again.
At C:\BC_Scripts\DistributionList.ps1:9 char:3
+  > <<<< c:\at.csv
    + CategoryInfo          : ObjectNotFound: (>:String) [], CommandNotFoundEx
   ception
    + FullyQualifiedErrorId : CommandNotFoundException
0
 
malarkieAuthor Commented:
Just saw your post.  Let me check.
0
 
malarkieAuthor Commented:
sorry, I thought I ran yours earlier, however I just ran your script and received the following;

Get-DistributionGroupMember : Cannot bind argument to parameter 'Identity' beca
use it is null.
At line:1 char:52
+ $grps | %{$n = $_.name; Get-DistributionGroupMember <<<<  $_} | Select-Object
 name,@{label="Group";expression={$n}} | export-csv c:\list3.csv
    + CategoryInfo          : InvalidData: (:) [Get-DistributionGroupMember],
   ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
   icrosoft.Exchange.Management.RecipientTasks.GetDistributionGroupMember
0
 
AkhaterCommented:
This one


Get-DistributionGroup -resultSize unlimited | select name -expand emailAddresses | where {$_.smtpAddress} | Export-Csv c:\t.txt
0
 
malarkieAuthor Commented:
That worked perfectly.  Thank you very much for your help, and with your patience.  I sincerly appreicate it.
0
 
AkhaterCommented:
You are welcome and thanks for the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

WEBINAR: 10 Easy Ways to Lose a Password

Join us on June 27th at 8 am PDT to learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees. We'll cover the importance of multi-factor authentication and how these solutions can better protect your business!

  • 6
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now