In Exchange Server 2007, you can use Windows PowerShell commands via Exchange Management Shell to manage standard and dynamic groups. In “Using PowerShell to Manage Groups, Part 1,” September 2007, InstantDoc ID 96699, I covered some of the basics about Windows and Exchange groups and Exchange Management Shell commands. Plus you saw how PowerShell is used to enable standard groups and work with group properties. Now I want to show you how to use PowerShell to maintain group membership and work with dynamic groups.
Maintaining Group Membership
Exchange administrators regularly maintain group memberships. Working with the shell, you use the Add-DistributionGroupMember command to add a member to a group, like this:
Add-DistributionGroupMember -id `
'Editors' -Member 'Eoin Redmond'
You must provide a pointer to the new member that Exchange can resolve. This can be a distinguished name (DN) such as “CN=Alan Kerr, OU=Exchange, DC=XYZ, DC=COM,” a user principal name (UPN) such as Joe.Jones@xyz.com, an alias, or a display name (used in the example). If you have more than a few members to add, you can do so by using a basic PowerShell trick—create a table, then pipe the table as input to the Add-DistributionGroupMember command, as follows:
"Jack Smith", "Jane Doe", `
"Molly Maguire" | `
Add-DistributionGroupMember `
-id 'Editors'
You can also scan mailboxes and apply a filter to discover members you want to add to a group. Here’s a one-line command that scans for mailboxes belonging to the “New York” office, then adds them to a group: . . .

