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

Exclusion switches do not work #54

Open choffman91 opened 2 years ago

choffman91 commented 2 years ago

I have the switches to ExcludeContactsWithoutPhoneNumber and ExcludeSharedMailboxContacts enabled, but contacts that are under both categories still sync

grahamr975 commented 2 years ago

Choffman,

The ExcludeSharedMailboxContacts switch does not sync contacts that don't have a WindowsEmailAddress and a legitimate mailbox. Secondly, the ExcludeContactsWithoutPhoneNumber switch does not sync contacts that don't have a Phone or Mobile phone. Hopefully, this helps clear up any confusion. Could you please include a sanitized log?

choffman91 commented 2 years ago

Thanks for the quick response.

I am working sanitizing a long, but I can tell you that all of our shared mailboxes are being synced. I will get the sanitized log added soon.

choffman91 commented 2 years ago

I think I have something wrong with my syntax of running the batch file:

PowerShell.exe -ExecutionPolicy Bypass ^ -File "%CD%\EWSContactSync.ps1" ^ -CredentialPath "REDACTED" ^ -FolderName "REDACTED" ^ -IncludeNonUserContacts Enabled ^ -ExcludeSharedMailboxContacts Enabled ^ -MailboxList DIRECTORY ^ -LogPath "REDACTED" ^ -ModernAuth

grahamr975 commented 2 years ago

@choffman91

Try the below instead

PowerShell.exe -ExecutionPolicy Bypass ^ -File "%CD%\EWSContactSync.ps1" ^ -CredentialPath "REDACTED" ^ -FolderName "REDACTED" ^ -IncludeNonUserContacts ^ -ExcludeSharedMailboxContacts ^ -MailboxList DIRECTORY ^ -LogPath "REDACTED" ^ -ModernAuth

choffman91 commented 2 years ago

Well that one ran at least, but it all of the shared contacts and regular users.

GALSync Log.txt

grahamr975 commented 2 years ago

@choffman91

After reviewing the code again, can you please try to set HiddenFromAddressListsEnabled to true for the mailboxes you want to hide from the script/GAL? Let me know if this solution works for you. https://docs.microsoft.com/en-us/exchange/address-books/address-lists/manage-address-lists