none
Distribution Group Members Export RRS feed

  • Question

  • I need to export distribution group members, which is simple enough, but I need certain formatting in the export that I can't seem to get right.

    First, I need to import a CSV file with the names of the groups I want to query and then in the export, I need to include the group name along with the primarysmtpaddress of the group members. I just can't seem to include the group name field in any of the exports. Any examples that I can use?

    Thanks.


    MCITP Exchange 2010 | MCITP Lync Server 2010 | MCTS Windows 2008

    Sunday, July 3, 2016 8:32 PM

Answers

  • Import-Csv D:\Test\DistGRP.csv | ForEach-Object {
        $Group = $_.name
            Get-DistributionGroupMember -Identity $Group | 
                   Select-Object Name,PrimarySmtpAddress,@{Label = 'Group'; Expression = { $Group } }
                                                       } #Foreach

    DistGRP.csv

    Name
    Sales
    Legal
    HR
    Sunday, July 3, 2016 9:24 PM

All replies

  • Import-Csv D:\Test\DistGRP.csv | ForEach-Object {
        $Group = $_.name
            Get-DistributionGroupMember -Identity $Group | 
                   Select-Object Name,PrimarySmtpAddress,@{Label = 'Group'; Expression = { $Group } }
                                                       } #Foreach

    DistGRP.csv

    Name
    Sales
    Legal
    HR
    Sunday, July 3, 2016 9:24 PM
  • I have a distribution group export script that may be what you're looking for:

    https://gallery.technet.microsoft.com/Distribution-Group-Report-d32c4788

    Friday, July 22, 2016 3:25 AM
  • $DG=Import-Csv -Header "DisplayName" $GroupNamesFile 

    foreach($item in $DG) 

    {   

    Get-DistributionGroupMember -Identity $item.displayname | Select-Object Name,PrimarySMTPAddress,@{Label='GroupName';Expression={$item}} | Export-csv GrpMember.csv -Append

    }

    If the member doesn't have mailbox, then there is no PrimarySMTPAddress. If you need more attributes along group and members, you can try below script.

    Export Distribution Group and Members to CSV

    Script Highlights:

    • Allows you to filter the report result based on group size(i.e., Members count).
    • Output can be filtered to list Empty group. i.e., Distribution Group without members
    • The script can be executed with MFA enabled account.
    • You can choose to either “Export Members of all Distribution Lists” or pass an input file to “Export Members of Specific Distribution List”.
    • You can filter the output based on whether the group accepts message from external senders or not.
    • Exports the report result to CSV.
    • Above all, script exports output in nicely formatted 2 CSV files. One with detailed information and another with summary information.


    • Proposed as answer by Robert_Luck Friday, May 24, 2019 7:10 AM
    Friday, May 24, 2019 6:16 AM