Save the code below 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
}
}
Saved the file as c:\DGMemebrship.ps1 and executed it using the following command:
./DGMemebrship.ps1