I'm trying to get the list of DL groups user is member of in O365. I'm using below PS Script but I'm getting the error message.
$user = "test1@rtest.com"$dlGroups =Get-DistributionGroup | Get-DistributionGroupMember | Where-Object {$_.PrimarySmtpAddress -eq $userEmail}foreach($dl in $dlGroups){ Write-Output $dl#Remove-DistributionGroupMember -Identity $dl.Identity -Member $user}
error:
Write-ErrorMessage : ||The operation couldn't be performed because 'Bus Training School' matches multiple entries.