PowerShell: Remove Users from AD Group Using a CSV
A PowerShell script to remove users from an AD group using a CSV of email addresses, updated for 2026 with dry runs, error handling and an audit log.
How to require approval for emails sent to an Active Directory distribution group: the two AD attributes behind it, plus the supported Exchange method in 2026.

A common request from management is simple: nobody should be able to email the whole staff list without someone approving it first. In Exchange this is called moderation, or distribution group message approval. When I first set it up in 2019, I did it straight in Active Directory, and the approach still explains what is happening underneath.
A distribution group does not hold messages for approval by default. Anyone allowed to send to it can do so, and the message goes straight out to every member.
Moderation is switched on by two Exchange attributes stored on the group object in Active Directory. Microsoft's Exchange team maps them directly in its Demystifying Moderation article:
| Exchange setting | AD attribute |
|---|---|
| ModerationEnabled | msExchEnableModeration |
| ModeratedBy | msExchModeratedByLink |
This is what I wrote back then, and it worked:
One correction to my old note: I wrote "add the CN" of each approver. In practice msExchModeratedByLink is a linked attribute, so it stores the full distinguished name (DN) of each moderator, for example CN=Approver One,OU=Staff,DC=contoso,DC=com, not just the CN.
The attributes are still the right ones, but I no longer recommend editing them by hand. The Exchange cmdlets and the admin center validate what you enter, while a raw attribute edit can leave a bad value behind that is hard to trace later. Microsoft does not say direct editing is unsupported; this is my advice from experience.
Get-DistributionGroup "[email protected]" |
Format-List Name,ModerationEnabled,ModeratedBy,ManagedBy,BypassModerationFromSendersOrMembers
Set-DistributionGroup "[email protected]" -ModerationEnabled $true `
-ModeratedBy "[email protected]","[email protected]"
Set-DistributionGroup "[email protected]" `
-BypassModerationFromSendersOrMembers "[email protected]"
Note that this replaces the existing list. Check the values from step 1 before overwriting them.
ManagedBy) approve messages instead.Get-DistributionGroup command from step 1 again. ModerationEnabled should be True and ModeratedBy should list your approvers.Get-DistributionGroup command before changing anything. Parameters such as ModeratedBy and BypassModerationFromSendersOrMembers replace values rather than add to them.The takeaway: the two AD attributes from my 2019 note still drive message approval, but set them through Exchange, on a supported version, and let the tools do the validation for you.
📝 First written from my own work in 2019; updated and expanded in November 2026 with AI assistance, keeping my original fix. Spotted something wrong? Tell me.