List empty distribution groups

A short tip on how to list all empty distribution groups. In this example I export the results to a csv file.

$DistributionGroups = Get-DistributionGroup -Resultsize Unlimited
$DistributionGroups |? {!(Get-DistributionGroupMember $_)} | Select-Object Name | Export-Csv "C:\EmptyDistributionGroups.csv"
Advertisements

Small script to list a users distribution group memberships in Exchange 2007 and 2010

I have created a small script to list the current group membership for a specific user. Save the code to a ps1 file and execute.

$User = read-host -Prompt "Enter Username"
"User " + $User + " is a member of the following groups:"

ForEach ($Group in Get-DistributionGroup)
{
   ForEach ($Member in Get-DistributionGroupMember -identity $Group | Where { $_.Name –eq $User })
   {
      $Group.name
   }
}

For example, I saved the file as c:\DGMemebrship.ps1 and executed it using the following command:
./DGMemebrship.ps1

DGMembership