grahamr975 / EWS-Office365-Contact-Sync

Uses Exchange Web Services to synchronize a Global Address List in Office 365 to a user's mailbox
MIT License
96 stars 21 forks source link

Add support for Distribution list \ Mail-enabled Security group #38

Open OfirGavish opened 3 years ago

OfirGavish commented 3 years ago

Hi, I'm trying to use the script but instead of syncing the GAL to all users, I want to sync the GAL with specific Distribution lists \ Mail-enabled Security Groups. I'm trying to add the required commands to the script but I'm having difficulties.

grahamr975 commented 3 years ago

Hello, @OfirGavish

You don't need to make any significant modifications to the script since the MailboxList parameter supports a list of emails. Unfortunately, Batch does not support PowerShell lists. So, you'll need to either launch the ContactSync script from another PowerShell script instead of Batch or hardcore your emails into the EWSContactSync.ps1 MailboxList parameter so it looks like my example below.

[Parameter(Mandatory=$False)] [String[]] $MailboxList = @(email1, email2, email3),

OfirGavish commented 3 years ago

I see, I was trying to add something like this using Exchange online powershell connection:

-----------------------------------------------------------{Fetch Distribution list members}--------------------------------------

$DLGroupMembers = Get-DistributionGroupMember -Identity ManagementGroup foreach ($Member in $DLGroupMembers) { Get-Mailbox -Identity $Member

and then use the right attribute of the member in the $mailbox variable.