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
99 stars 21 forks source link

switches not syncing intended users #78

Closed rypto closed 1 year ago

rypto commented 1 year ago

I've had this weird problem for a while now where I use the script with the -ExcludeSharedMailboxContacts and -ExcludeContactsWithoutPhoneNumber and only a portion of the users that suppose to get synced actually get synced.

When I compare two users in AD, one getting synced with another not getting synced, I can't seem to find any differences. They both are identical with the same attributes. What can I check? Please

Robs90 commented 1 year ago

Please see my Issue: https://github.com/grahamr975/EWS-Office365-Contact-Sync/issues/80 It could be that on the Usser, the WindowsEmailAddress ist written with Capital Letters, and the PrimarySMTPAddress is not (or vice versa).

rypto commented 1 year ago

Thanks Robs90 it seems to be it. I tried and changed the last part of the code on line 66 of Get-GAL-Contacts.ps1 as you provided in the other thread | Where-Object {$EmailAddressList -Contains $.WindowsEmailAddress} but I get errors when running the script. Did you encountered them too?

image

Robs90 commented 1 year ago

No I did not, could it be that you changed the Filename of the Get-Calcontacts.ps1 File when editing it? Or maybe saved it as something else than a .ps1 File? If that´s the case, it doesn´t import it as a Function

rypto commented 1 year ago

no, just edited it, no filename changes. So you only changed that last part and nothing else and nowhere else?

Robs90 commented 1 year ago

To make this work, we did not change anything else. Other changes were made, but only after testing this.

I did have this error when I added another Module to the Script (unrelated Changes), which turned out to be an error in the very first line of the .PS1 (the one starting with "function". ). In that case it turned out to be, that in that first line, the name of the function (Get-GALContacts in your case) was changed. Now these were errors I generated myself, but please verfify if the first line still looks like this:

function Get-GALContacts {

rypto commented 1 year ago

It does...

rypto commented 1 year ago

Ok, so I tried with this line and it worked :-) | Where-Object {$EmailAddressList -contains $_.WindowsEmailAddress}

Robs90 commented 1 year ago

Thanks for the Feedback. Will check in my script and edit the post if needed, might have been an error just in my posted Code on Github.

grahamr975 commented 1 year ago

I applied this fix in commit e6da2a4173219401aa60ecd6aa991916077a9a77. Closing the ticket...