Script to copy mail enabled security groups to distribution lists - Exchange Online

Job ID: 35565823

Budget: €30 – €250 EUR

We have a hybrid AD/AAD and Exchange / Exchange online solution. On-prem we have about 70 mail enabeled security groups, that is placed in an OU in AD that is synced to EXO. In order to allow end users to be owner of these groups and add/remove members in the group, we would like to convert the mail enabled security groups to distribution lists. We would like to use powershell to automate this.
We want to copy each mail enabled security group (cloud) to a new distribution list (also cloud). Since two groups cannot have the same name, each copied group must have a prefix like "new-". All attributes of the original mail enabled security group must be copied. That is members, owners, email addresses, aliases, displayname X.500 and all other relevant info. You know what needs to be copied.
After all the groups are copied, we would like to have another powershell script that moves all the mail enabled security groups to an OU that is not synced to Azure. The mail enabled security groups online should then be removed by the sync. The script must also mail-disable the on-prem mail enabled security groups.
Last action will be to remove the "new-" prefix from the distribution lists online.