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 })

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