Find all the Distribution Groups a user is a member of with PowerShell in Office 365


Whether you want to do some reports or debugging, you might need to quickly find out what Distribution Groups a user is a member of! You could go in the user’s profile, see all of the groups , find out which ones are Security, which ones are Distribution Groups.. or you could do an easy PowerShell cmdlet!

Find all the Distribution Groups a user is a member of with PowerShell

Since we will be playing with Exchange Online, you first need to connect to Exchange!

$cred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $cred -Authentication Basic -AllowRedirection

Import-PSSession $Session

Next up, I will save the Username of the person I am looking for in a variable called Username

$Username = ""

And then, I will use this cmdlet which will get all the Distribution Groups in my tenant, and then find the ones where my username is in the members! (This assumes your e-mail address is the same as the username! If that’s not the case, you can simply put the e-mail in the UserName variable and it will work!)

$DistributionGroups= Get-DistributionGroup | where { (Get-DistributionGroupMember $_.Name | foreach {$_.PrimarySmtpAddress}) -contains "$Username"}

You can now either Display it , or do another action such as removing the user from all of them!

Find all the Distribution Groups a user is a member of with PowerShell in Office 365

That’s it! As you see this is really an quick and easy PowerShell snippet!

Leave a comment and don’t forget to like the Vlad Talks Tech Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
Previous Post
Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication
Next Post
Find all the Office 365 Groups a user is a Member of with PowerShell


  • January 10, 2019 at 7:59 am

    Hi Vlad , have you ever encountered “The operation couldn’t be performed because ” matches multiple entries.”?

    I’m only getting it for a few entries.


  • February 4, 2019 at 12:05 pm

    You get this error when running which cmdlet? I will try to replicate!

  • March 13, 2019 at 10:34 am

    I ran into the same problem but traced it down to groups having the same name. For instance we have a group called Interns which is a Distribution List. I would get the error Andy did, upon further research there was another group called Interns only this one was an O365 group not a distribution list. The second group RecipientTypeDetails was GroupMailbox instead of MailUniversalDistributionGroup. My workaround was to specify the RecipientTypeDetails
    get-distributiongroup $GroupName -recipientTypeDetails MailUniversalDistributionGroup

  • April 10, 2020 at 2:24 pm
    Deb Codding

    Thanks for sharing this. Just made my life a lot easier!

  • August 21, 2020 at 6:07 am

    this excellent script saves precious time


Leave a Reply

15 49.0138 8.38624 1 0 4000 1 300 1