none
Generate report

    Question

  • Hi,

    I want to create a report for all distributions groups and export them to csv.

    The csv format should look like "DG name, DG primary SMTP address, DG E-MailAddresses, DG members".

    Would someone please post some powershell examples for this request?

    Best regards,

    Tantony

    Friday, May 18, 2018 1:45 PM

All replies

  • Hi,

    Please try the following command in your environment, it works fine in my lab:

    Get-Group | where{$_.WindowsEmailAddress -notlike ""} | Select NAME,*address*,@{Expression={$_.Members};Label="Members";} | Export-Csv C:\shared\group.csv


    Below is the test result:

    Hope it helps.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, May 21, 2018 8:04 AM
    Moderator
  • Hi Manu,

    Get-Group only returns the primary E-Mail address, but not the additional E-Mail addresses.

    May you have another solution?

    Regards,

    Tantony

    Monday, May 21, 2018 8:42 AM
  • Hi Manu,

    Get-Group only returns the primary E-Mail address, but not the additional E-Mail addresses.

    May you have another solution?

    Regards,

    Tantony

    If you mind exporting the result to two CSV files?

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, May 21, 2018 8:48 AM
    Moderator
  • I want to have it done in one step.

    A copy & paste afterwards is error prone and troublesome.

    Regards,

    Tantony

    Monday, May 21, 2018 8:53 AM
  • If the additional e-mail addresses are quite important information for you, at present, the only way I can think of is using the two commands(Get-distributiongroup and Get-distributiongroupmember) and exporting the result to two csv files, because we couldn't get the group members and additional email addresses from one command. 

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, May 21, 2018 9:05 AM
    Moderator
  • Is there a way in PowerShell to combine both cmdlets (Get-distributiongroup and Get-distributiongroupmember) and format the output for exporting to csv?

    Reagrds,

    Tantony

    Monday, May 21, 2018 9:26 AM