We have a couple of customers that want to maintain distribution groups of external contacts that can be used company wide.
The way to do this as an Exchange admin is to create a Mail Contact for an external user first, and then add that mail contact to a distribution group. This can be quite an involved process, and you may not want to have users traversing the Exchange Admin Center to complete this sort of task.
To make this easier, we’ve put together a power shell script that you can download here.
Assign the minimum permissions
Any Global administrator will be able to run this powershell script, though if you want to give a user the ability to execute the commands, you’ll need to assign them to the appropriate role groups. These are Recipient Management and Organization Management. Keep in mind, even though these are the minimum permissions required to run this Powershell script, they still enable the relevant user to do pretty much everything within Exchange. For a full list of the permissions granted, see these links:
- Organization Management: https://technet.microsoft.com/en-us/library/dd335087(v=exchg.150).aspx
- Recipient Management: https://technet.microsoft.com/en-us/library/dd298028(v=exchg.150).aspx
To give a user the correct permissions, connect to Exchange Online via Powershell as a global administrator and run the following commands. Replace email@example.com with the identity of the relevant user.
Add-RoleGroupMember "Recipient Management" -Member firstname.lastname@example.org Add-RoleGroupMember "Organization Management" -Member email@example.com
Running the PowerShell Script
Once the user has been granted access they can run the powershell script under their own credentials.
- Download the script here.
- Rename it with a file extension of .ps1 eg. DistributionGroups.ps1
- Run the script by right clicking the file and choosing Run in Powershell
- Press 1, then Enter to connect to Exchange Online. Press Enter again once the commandlets have downloaded.
- Follow the menu items within the PowerShell script to perform the following actions:
- Add Mail Contacts to distribution groups
- Get a list of distribution groups
- Create a distribution group
- Get a list of distribution group members
- Remove a contact from all distribution groups