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

Contact beeing excluded with -ExcludeSharedMailboxContacts if Emailaddress is in capital letters #55

Closed christianneeb closed 1 year ago

christianneeb commented 2 years ago

Hi,

first of all: Really great job with the script! we run into the problem, that for some human error a couple of users were created with capital letters in their username and therefor in their email address. We can change that username and alias in Exchange and AD no problem, but for some reason the Get-GALContacts.ps1 still shows the email with capital letters. Even after a couple of days, because the GAL is only updated once a day (maybe?).

So after digging into the script i found out i need to alter the following in line 59 Get-GALContacts.ps1. I also added the "HomePhone" attribut in there, because we want to sync those fields also.

$ContactList = $ContactList | Select-Object DisplayName,FirstName,LastName,Title,Company,Department,WindowsEmailAddress,Phone,MobilePhone,HomePhone | Where-Object {$EmailAddressList.Contains($_.WindowsEmailAddress)}

The new one:

$ContactList = $ContactList | Select-Object DisplayName,FirstName,LastName,Title,Company,Department,WindowsEmailAddress,Phone,MobilePhone,HomePhone | Where-Object {$EmailAddressList.Contains($_.WindowsEmailAddress.ToLower())}

Now the scripts creates all the contacts in the user mailbox.

Thanks, Christian

PS: I also added two other features for the script: a) Use an Active Directory Group for selecting the user who receives the contacts in their Outlook and b) Populate the the "HomePhone" and "FileAs" in the created contact. Should i open another "issue" if you are interested?

grahamr975 commented 2 years ago

@christianneeb

Good work on this. I'll work on fixing the filtering within the main script as time allows.

Regards, Ryan

grahamr975 commented 1 year ago

This has been fully fixed by commit e6da2a4173219401aa60ecd6aa991916077a9a77