Handy way to manage Distro List maintenance

Some organizations end up having cluttered distribution lists still populated with mailboxes belonging to employees who have left the company. One strategy I’ve employed is when an employee leaves, to add their mailbox to a Distribution List I call “Sunset”. That list contains all non-active employees whose mailboxes have not been deleted yet.

Once the mailbox is listed there, I can simply run the following script.

$allgroups=get-distributiongroup -filter {DisplayName -ne "Sunset"}
Get-DistributionGroupMember Sunset | remove-distributiongroupmember $allgroups

This checks every distribution group’s membership against the Sunset DL’s membership and removes any members of the Sunset list from the other lists.