Export Distribution Group details

When you have multiple Distribution Groups in your Exchange 2007 environments and you need an overview of the members per Distribution Group, you want to script this action. Whit the following script you can export all Distribution Groups in an Organizational Unit with the following information: Groupname, Primary SMTP address, Members. This will save a lot of time, while you don’t have to click around all your groups in Active Directory 🙂

All you have to change is the OU$=”edir”.

If your Organizational Unit is called “Distribution Groups“, it will be: OU$=”Distribution Groups”

_____________________________

## This script will get all distrobution Groups and print out
## the Group Name and Members alias and Primary smtp address
##
## Example
## groupName: Group.Name
##
## alias               PrimarySmtpAddress
## —-              ——————
## Group.Alias    Group@primarySmtpAddress 
##
## groupsMembers:
##
## alias               PrimarySmtpAddress
## —-              ——————
## User.Alias      User@primarySmtpAddress

$OU=”edir”
##input OU path above

foreach($group in Get-DistributionGroup -OrganizationalUnit $Ou)
{
write-output “GroupName:$group ”
Get-DistributionGroup $group | ft alias,primarysmtpaddress
Write-output “GroupsMembers:”
Get-DistributionGroupMember $group | ft alias,primarysmtpaddress
write-output ‘ ‘
}
_____________________________

Here you can see the output of the script in the Exchange 2007 test environment.

Leave a Reply