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

Need to add exclusion list #19

Closed dmaglinte77 closed 4 years ago

dmaglinte77 commented 4 years ago

Good morning. I have the script working in my environment, but I was curious if there was a way to put in an exclude list? I have about 15 numbers that we don't want to sync, but their AD accounts have phone numbers that need to stay.

Thanks!

dmaglinte77 commented 4 years ago

In my scenario, I needed to exclude ipads from being copied. We ended up putting "ipad" in the Notes section and then used that as a filter to exclude:

$ContactList = Get-User -Filter { (WindowsEmailAddress -ne $null) -and _(Notes -ne "ipad") } -ResultSize unlimited

I'm sure there are other ways, but this is how I handled it.