How to Remove Distribution Group Membership Using Powershell in Exchange 2010

 

$DGs= Get-DistributionGroup –ResultSize Unlimited
$DGs | where { (Get-DistributionGroupMember $_ –ResultSize Unlimited | foreach {$_.PrimarySmtpAddress}) -contains “TestUser1@prem.com”}
foreach( $dg in $DGs){Remove-DistributionGroupMember $dg -Member TestUser1@prem.com}

Leave a Reply

Your email address will not be published. Required fields are marked *