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

Apply the script only user mailboxes #95

Open AisaacOcean opened 9 months ago

AisaacOcean commented 9 months ago

Hello, Would it be possible to apply the scripts only for the user mailboxes, we do not want to do it also in the shared mailboxes?

grahamr975 commented 8 months ago

@AisaacOcean If you have a list of your user's emails, you can manually pass those in a list to the -MailboxList parameter

philipfredberg commented 8 months ago

Hi @AisaacOcean,

I tried passing a list to -MailboxList parameter, via this command (Get-Content -Path "file.txt") however is says vaule is empty. If i run Get-Content -Path "file.txt" alone, it works and it has worked in you script before, can you perhaps tell me how to correctly pass the list?

TheMechanicX32 commented 7 months ago

@AisaacOcean @grahamr975

I made a few changes to your powershell script that may be useful.

I had the same issue, couldn't figure out how to filter out shared mailboxes. After pouring through MS docs and your code, I found it will work if you make the following modification in Get-GALContacts.ps1:

image

Here is the modified script in a format that can be pasted:

$ContactList = Get-User -Filter "(RecipientTypeDetails -eq 'UserMailbox')" -ResultSize unlimited | Select-Object DisplayName,FirstName,LastName,Title,Office,WindowsEmailAddress,Phone

There are a bunch of filter parameters you can use. Here is a complete list from the Microsoft Documentation:

Make sure you include the -ExcludeSharedMailboxContacts in your batch script.