Get the App
SLTechnology News&Howtos  ›  Servers  › 

Delete users in the entire forest distribution group

Shulou Source: shulou.com Published: 2022-06-02 09:09:40 10月03日 Update

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.

Tags: Script Zhang San user Communication Distribution Group Forest Enterprise Server problem Service run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information Apple Shulou Technology Linux