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

Sync only enabled user accounts #40

Closed Bananovics closed 3 years ago

Bananovics commented 3 years ago

Hi Ryan!

If possible how can I reach that only AD enabled user accounts create as contacts with your script? Currently if a user left the company and the phone number which was belinging to him/her moved to another user the same phone number will present on both contacts. Thats why I would like to create contacts only for AD enabled users as those who left the company are in disabled state.

Cheers!

Bananovics commented 3 years ago

Solved by myself :)

rypto commented 3 years ago

Hi, how did you solve this?

Bananovics commented 3 years ago

Hi!

I added a condition when import GAL to $contactlist. I used $ContactList = Get-User -ResultSize unlimited | Where {$.SKUAssigned -eq "TRUE" -and $.UserAccountControl -eq "NormalAccount"} instead of $ContactList = Get-User -ResultSize unlimited

You can find these lines in EWSContacts\Module\functions\contacts\Get-GALContacts.ps1 line 53.

Cheers!

rypto commented 3 years ago

Thanks! I replaced the line but get an error

Where : The term '$.SKUAssigned' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:34

Any idea?

Bananovics commented 3 years ago

You can run only command Get-User -ResultSize unlimited | Where {$.SKUAssigned -eq "TRUE" -and $.UserAccountControl -eq "NormalAccount"} in PS and check the result. If it starts to listing user mailboxes it is good.

Chudinnio commented 2 years ago

Hi all, I got same issue when i start only this command: Get-User -ResultSize unlimited | Where {$.SKUAssigned -eq "TRUE" -and $.UserAccountControl -eq "NormalAccount"}

The result is: Where : The term '$.SKUAssigned' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:34

Any idea how reslove it?

Bananovics commented 2 years ago

Hi!

There is a _ character missing after $ signs. For some reason Github cut it out from comment..

Attached in right format as picture. Screenshot 2021-11-25 081853

Chudinnio commented 2 years ago

@Bananovics Thank you very much for your realy fast help! It works perfectly. We can close case.