The script creates a distribution list in Microsoft 365 (Office 365) based on an Active Directory group object. It also copies the memberships of the AD group and assigns the group owner in Microsoft 365 (Office 365).
The script can be used to add users to groups by department. It adds a user to a group with the same name as the user's department. If a group with the necessary name does not exist it will be created.