Managing Exchange Server Distributions groups using PowerShell

If you happen to have 300+ distribution groups on your Exchange Server, you are bound to end with the same problem I had a few days ago. The problem was a pretty straightforward. I had to first find all the distribution groups that had a specific user as a Manager and than grant manager rights to another user without loosing the other Managers. If you try it from the Exchange Management Console, you can bulk edit the Managed By field, but as soon as you start typing the name of the additional manager you are going to lose the previous Managed By entries.

The solution was to use the Exchange Management Shell and PowerShell to bulk edit the distribution groups.

The easiest way to do it by first selecting all the groups that have the user as their Manager:

Get-DistributionGroup | where {$_.ManagedBy -like “*Ugrin*”}

You can save it in a file just as a backup so you will have something to compare with after you make the changes.

You can than pipe the list of Distribution Groups into a Set-DistributionGroup command that would make the change for every distribution group.

Get-DistributionGroup | where {$_.ManagedBy -like “*Ugrin*”} | Set-DistributionGroup -ManagedBy ugrin@domain.com, vojdan@domain.com

Just make sure that you include the original user as a manager so you wouldn’t have to add it again in the end.

The same syntax can be used for adding members to a distribution group when you know the manager.

Get-DistributionGroup | where {$_.ManagedBy -like “*Ugrin*”} | Add-DistributionGroupMember -Member vojdan@domain.com,lili@domain.com

 

This entry was posted in Exchange Server 2007, Exchange Server 2010, Exchange Server 2013, PowerShell and tagged , , , . Bookmark the permalink.

Leave a Reply

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