How to manage Distribution Group in Exchange Online in Hybrid Environment

Introduction

This script is used to help user managing DG in cloud side.

Scenarios

After Hybrid is set up, the user mailbox, who was moved to cloud side, can't manage the DG created in On-Premise Exchange. This script will create a DG with prefix "EXO".  All option can be changed with this DG, and this script can reflect the configuration changes back to on premise DG. 

Script

You can use this script in the following way.

1. Open Windows PowerShell.

2. Type the one command< Script Path> at the Windows PowerShell Console.

For example, type C:\Script\ EXOManagingDGInEAC

Here are some code snippets for your references.

PowerShell
Edit|Remove
Set-DistributionGroup -Identity $OnPremiseGroup.Name -MemberDepartRestriction $EXOGroup.MemberDepartRestriction -MemberJoinRestriction $EXOGroup.MemberJoinRestriction `
                   -ModeratedBy $EXOGroup.ModeratedBy -ModerationEnabled $EXOGroup.ModerationEnabled -SendModerationNotifications $EXOGroup.SendModerationNotifications -BypassSecurityGroupManagerCheck
           Update-DistributionGroupMember -Identity $OnPremiseGroup.Name -Member $members -BypassSecurityGroupManagerCheck -confirm:$false

Examples

       Example 1: Create new DG in cloud side or reflect the configuration back to On-Premise Exchange

The sample is showed below
EXOManagingDGInEAC.ps1

       Command Screenshot
:

 

Prerequisites

Exchange Online
Windows PowerShell 2.0

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.