Export all distribution Group and All members using PS Script-Exchange 2007&2010
Script Supports - Exchange 2007,2010,2013
In some situations we had to Export all the Distribution group and all the members of it to a CSV file
I have wrote a script which will make Exchange Administrators life Easy
Change LogV1.1, 02/07/2014 - Added "Enter the Distribution Group name with Wild Card"
.Requires -version 2 – Runs in Exchange Management Shell
.\DistributionGroupMemberReport.ps1 – It Can Display all the Distribution Group and its members on a List
Or It can Export to a CSV file
Download the Script
Browse the Shell to the Appropriate Location
Run it as above
Output of CSV file look like Below
You can add some more entries if required
I have wrote a script which will make Exchange Administrators life Easy
Change LogV1.1, 02/07/2014 - Added "Enter the Distribution Group name with Wild Card"
.Requires -version 2 – Runs in Exchange Management Shell
.\DistributionGroupMemberReport.ps1 – It Can Display all the Distribution Group and its members on a List
Or It can Export to a CSV file
Download the Script
Browse the Shell to the Appropriate Location
Run it as above
Output of CSV file look like Below
You can add some more entries if required
PowerShell
<# .Requires -version 2 - Runs in Exchange Management Shell .SYNOPSIS .\DistributionGroupMemberReport.ps1 - It Can Display all the Distribution Group and its members on a List Or It can Export to a CSV file Example 1 [PS] C:\DG>.\DistributionGroupMemberReport.ps1 Distribution Group Member Report ---------------------------- 1.Display in Shell 2.Export to CSV File Choose The Task: 1 DisplayName Alias Primary SMTP address Distriubtion Group ----------- ----- -------------------- ------------------ Atlast1 Atlast1 Atlast1@targetexchange.in Test1 Atlast2 Atlast2 Atlast2@careexchange.in Test1 Blink Blink Blink@targetexchange.in Test1 blink1 blink1 blink1@targetexchange.in Test1 User2 User2 User2@careexchange.in Test11 User3 User3 User3@careexchange.in Test11 User4 User4 User4@careexchange.in Test11 WithClient WithClient WithClient@careexchange.in Test11 Blink Blink Blink@targetexchange.in Test11 blink1 blink1 blink1@targetexchange.in Test11 Example 2 [PS] C:\DG>.\DistributionGroupMemberReport.ps1 Distribution Group Member Report ---------------------------- 1.Display in Shell 2.Export to CSV File Choose The Task: 2 Enter the Path of CSV file (Eg. C:\DG.csv): C:\DGmembers.csv .Author Written By: Satheshwaran Manoharan Change Log V1.0, 11/10/2012 - Initial version #> Write-host " Distribution Group Member Report ---------------------------- 1.Display in Exchange Management Shell 2.Export to CSV File" -ForeGround "Cyan" #---------------- # Script #---------------- Write-Host " " $number = Read-Host "Choose The Task" $output = @() switch ($number) { 1 { $AllDG = Get-DistributionGroup -resultsize unlimited Foreach($dg in $allDg) { $Members = Get-DistributionGroupMember $Dg -resultsize unlimited $Total = $Members.Count $RemoveNull = $Total-1 For($i=0;$i -le $RemoveNull;$i++) { $userObj = New-Object PSObject $userObj | Add-Member NoteProperty -Name "DisplayName" -Value $members[$i].Name $userObj | Add-Member NoteProperty -Name "Alias" -Value $members[$i].Alias $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $members[$i].PrimarySmtpAddress $userObj | Add-Member NoteProperty -Name "Distriubtion Group" -Value $DG Write-Output $Userobj } } ;Break} 2 { $CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\DG.csv)" $AllDG = Get-DistributionGroup -resultsize unlimited Foreach($dg in $allDg) { $Members = Get-DistributionGroupMember $Dg -resultsize unlimited $Total = $Members.Count $RemoveNull = $Total-1 For($i=0;$i -le $RemoveNull;$i++) { $userObj = New-Object PSObject $userObj | Add-Member NoteProperty -Name "DisplayName" -Value $members[$i].Name $userObj | Add-Member NoteProperty -Name "Alias" -Value $members[$i].Alias $userObj | Add-Member NoteProperty -Name "RecipientType" -Value $members[$i].RecipientType $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $members[$i].PrimarySmtpAddress $userObj | Add-Member NoteProperty -Name "Distriubtion Group" -Value $DG $output += $UserObj } $output | Export-csv -Path $CSVfile -NoTypeInformation } ;Break} Default {Write-Host "No matches found , Enter Options 1 or 2" -ForeGround "red"} }
Yorumlar