Delete users in the entire forest distribution group
A few days ago, the user proposed that the user "Zhang San" should be deleted from all distribution groups in many Exchange distribution groups.
You can delete it using the following script:
# set the entire forest Set-ADServerSettings-ViewEntireForest $true# to view the distribution group $GroupNum = Get-DistributionGroupForeach ($Groups in $GroupNum) {$GroupMember=Get-DistributionGroupMember-Identity $Groups.nameif ($GroupMember.Name-eq "Zhang San") {Remove-DistributionGroupMember-Identity $Groups-Member "Zhang San"-Confirm:$false$Groups}}
Save the above script as a PowerShell script, then open Exchange Manager Shell on the Exchange server and run the script.
Note: replace Zhang San in the script with the user who needs to be deleted; in large enterprises, DisplayName may have the same name, so pay attention to the problem of duplicate name.