Microsoft Exchange Online
A Microsoft email and calendaring hosted service.
1,870 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have dynamic distribution lists in Exchange Online. I have a user and want to find out which dynamic distribution lists this user is a member of. I want to try something like the following, but I’m not sure if it's correct
Get-DynamicDistributionGroup -ResultSize Unlimited | Where-Object { (Get-DistributionGroupMember $_.Identity).PrimarySmtpAddress -eq 'user1@contoso.com' }
Hi @Glenn Maxwell ,
Welcome to the Microsoft Q&A platform!
Based on your description, I understand you want to find out which dynamic distribution lists the user is a member of via PowerShell.
After my test, you could do this with the following script as the screenshot shows.
$userEmail = "user@example.com"
$dynamicDLs = Get-DynamicDistributionGroup
foreach ($dl in $dynamicDLs) {
$filter = $dl.RecipientFilter
$members = Get-Recipient -RecipientPreviewFilter $filter
if ($members.PrimarySmtpAddress -contains $userEmail) {
Write-Output "$($userEmail) is a member of $($dl.Name)"
}
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it.