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

How can I get a list of Exchange Contacts not in any distribution groups?

I am trying to pull a list of all the email contacts in our Exchange 2010 environment that are not a member of any group. I want to find contacts not in the groups so I can eventually remove them from our system.

Any suggestions on how to accomplish this in Powershell or with a script?
1 Solution
The technet link below includes an example using powershell to see all the distribution groups a user belongs to.

Your inquiry will be to nest two one listing all contacts, and then comparing whether they are:


The example is a mix, I presume
Here is a set of available cmdlets for exchange 2010.
Try this.....
foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | sort displayname | ft @{expression={$_.displayname};Label=”$group”} | Out-File c:\temp\DistributionListMembers.txt -append}

This will generate better output.

foreach ($group in Get-DistributionGroup | sort displayname) { get-distributiongroupmember $group | sort displayname | ft @{expression={$_.displayname};Label=”$group”} | Out-File c:\temp\DistributionListMembers.txt -append}
Minecraft_ EndermanCommented:
I have a script that will tell you what distribution groups a user is a member of.

$User = read-host -Prompt "Enter Username"
$user_dn = (get-mailbox $user).distinguishedname
"User " + $User + " is a member of the following groups:"
foreach ($group in get-distributiongroup -resultsize unlimited){
if ((get-distributiongroupmember $group.identity | select -expand distinguishedname) -contains $user_dn){$group.name}

Hope this will be helpful for you.
itregosaAuthor Commented:
Thanks everyone, but these aren't quite what I'm looking for. Instead of listing all of the members of the groups, I'm trying to list all the contacts without groups. Or if it is easier, all the contacts and their groups they are a member of. Any thoughts?
The examples provided do just that.
You list the recipients you have (first Loop)
Then you look for which groups they belong to (inner loop)

one example is prompting you for the user whose information you are interested in and then it lists which groups this account is a member of.

Do you have recipients who also have aliases?
regosa@yourdomain.com and itregosa@yourdomain.com end up in your mailbox? One account is the primary email address, while the other is an alias, secondary, tertiary ........

The other examples deal with listing all the distribution groups and their members.
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

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.

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