This script is intended to demonstrate how an Exchange Online distribution group can be converted to an Office 365 Group. Only mailboxes are supported in Office 365 Groups, so these are the only recipients moved across. The settings of the distribution group
are moved as is its email address (you might not like to do this). Some bugs are still present in the PowerShell cmdlets for Office 365 groups (such as the AccessType parameter to differentiate between public and private groups), but these will be fixed over
time. No guarantee is given as to the usefulness or validity of the code!
Make sure that your PowerShell session is connected to Exchanage Online and then run the script, providing the alias of the distribution group to convert as the parameter. The following processing is performed:
- Takes the alias or name of a distribution group as the input parameter.
- Performs some initial checks to see whether the distribution group exists or an Office 365 Group with the same alias exists. And that it’s an object of type
MailUniversalDistributionGroup, which is the only type we can convert.
- Checks the members of the input group to strip out those that can’t be added to the target Office 365 Group.
- Checks whether the input group has member join restrictions. If it has (the group is “Closed” or “ApprovalRequired”), the admin is prompted to decide whether they want to create a private Office 365 Group. You can’t currently
change the group type, so this is an important decision.
- Tells the admin what’s happening and asks to proceed.
- The new Office 365 Group is created with the New-UnifiedGroup cmdlet. It uses the same alias as the input distribution group because a new alias is given to that group.
- As many of the properties of the input distribution group as possible are moved to the new Office 365 Group (not all can be because there isn’t a direct 1-to-1 mapping between the two object types).
- In particular, the Office 365 Group is set to auto-subscribe new members so that it mimics the distribution of new content via email as members expect from a distribution group.
- The membership is added to the new Office 365 Group using the Add-UnifiedGroupLinks cmdlet.
- Group members can be in three sets of links (owners, members, and subscribers). Because the new Office 365 Group is intended to behave like an email distribution group, the members are added to the members and subscribers sets.
- The owners/managers of the input distribution group are added as owners of the Office 365 Group.
- The email address of the input distribution group is switched to the new Office 365 Group so that new traffic goes there.