EWS-Office365-Contact-Sync icon indicating copy to clipboard operation
EWS-Office365-Contact-Sync copied to clipboard

Add homePhone Number to Contacts

Open yo-que-se opened this issue 2 years ago • 2 comments

Would it be possible to add the homePhone Number to the contact information of each contact? I need to sync 3 different phone numbers, but only is possible to sync 2 phone numbers.

Thank's in advance

yo-que-se avatar Nov 14 '22 16:11 yo-que-se

I did add that to our scripts manually. #55

Edit Get-GALContacts.ps1 # If the ExcludeSharedMailboxContacts switch is enabled, exclude contacts that are a shared mailbox or mailbox with no liscense if ($ExcludeSharedMailboxContacts) { $DirectoryList = $(Get-EXOMailbox -ResultSize unlimited -PropertySets Minimum,AddressList | Where-Object {$_.HiddenFromAddressListsEnabled -Match "False"}) $EmailAddressList = $DirectoryList.PrimarySMTPAddress $ContactList = $ContactList | Select-Object DisplayName,FirstName,LastName,Title,Company,Department,WindowsEmailAddress,Phone,MobilePhone,HomePhone | Where-Object {$EmailAddressList.Contains($_.WindowsEmailAddress.ToLower())} } else { $ContactList = $ContactList | Select-Object DisplayName,FirstName,LastName,Title,Company,Department,WindowsEmailAddress,Phone,MobilePhone,HomePhone }

Edit Sync-Contactlist.ps1 Line 103 if ($null -eq $($MailboxContacts | Where-Object {(($_.GivenName -eq $Contact.FirstName) -or ("" -eq $Contact.FirstName)) -and (($_.Surname -eq $Contact.LastName) -or ("" -eq $Contact.LastName)) -and ($_.EmailAddresses[[Microsoft.Exchange.WebServices.Data.EmailAddressKey]::EmailAddress1].address -eq $Contact.WindowsEmailAddress) -and ($Contact.Company -eq $_.CompanyName -or $Contact.Company -eq "") -and ($Contact.Department -eq $_.Department -or $Contact.Department -eq "") -and (($_.DisplayName -eq $Contact.DisplayName) -or ($Contact.DisplayName -eq "")) -and ($Contact.Title -eq $_.JobTitle -or $Contact.Title -eq "") -and ($Contact.Phone -eq $_.PhoneNumbers[[Microsoft.Exchange.WebServices.Data.PhoneNumberKey]::BusinessPhone] -or $Contact.Phone -eq "") -and ($Contact.MobilePhone -eq $_.PhoneNumbers[[Microsoft.Exchange.WebServices.Data.PhoneNumberKey]::MobilePhone] -or $Contact.MobilePhone -eq "") -and (($Contact.HomePhone -eq $_.PhoneNumbers[[Microsoft.Exchange.WebServices.Data.PhoneNumberKey]::HomePhone]) -or ($Contact.HomePhone -eq "")) -and ($_.FileAs -eq $Contact.DisplayName)})) {

Line 134 New-EXCContactObject -MailboxName $Mailbox -DisplayName $Contact.DisplayName -FirstName $Contact.FirstName -LastName $Contact.LastName -EmailAddress $Contact.WindowsEmailAddress -CompanyName $Contact.Company -Department $Contact.Department -BusinssPhone $Contact.Phone -MobilePhone $Contact.MobilePhone -JobTitle $Contact.Title -FileAs $Contact.Displayname -Folder $ContactsFolderObject -useImpersonation -service $service

I also added the "FileAs" attribut in the sync to make sure the sorting in Outlook works as expected.

christianneeb avatar Jan 19 '23 09:01 christianneeb

Thanks a lot [christianneeb] !!!! Your code is working like a charm! Also i've implemented your solution for "Contact beeing excluded with -ExcludeSharedMailboxContacts if Emailaddress is in capital letters" and is working great!

Best regards.

yo-que-se avatar Mar 17 '23 09:03 yo-que-se