EWS-Office365-Contact-Sync
EWS-Office365-Contact-Sync copied to clipboard
Not working with error message
Dear,
I have follow the steps but still geting an error:
- create an .cred file for my admin account.
- Create an bat file with following rules: @echo off cd "%~dp0EWS-Office365-Contact-Sync"
PowerShell.exe -ExecutionPolicy Bypass ^ -File "C:\Users\cade\Desktop\EWS-Office365-Contact-Sync-master\EWSContactSync.ps1" ^ -CredentialPath "C:\temp\caglar.cred" ^ -FolderName "TEST Caglar" ^ name for the outlook contact folder. This folder does not exist. So it will create by it self on the user contact folder ? -LogPath "%~dp0Logs" ^ -MailboxList icttest@.....,nl ^ -ModernAuth pause
VERBOSE: Loading module from path 'C:\Users\cade\Desktop\EWS-Office365-Contact-Sync-master\EWSContacts\Module\bin\Microsoft.Exchange.WebServices.dll'.
TerminatingError(Import-Module): "Could not load file or assembly 'file:///C:\Users\cade\Desktop\EWS-Office365-Contact-Sync-master\EWSContacts\Module\bin\Microsoft.Exchange.WebServices.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)"
i have also unlbock de dll files. now see this error: A constructor was not found. Cannot find an appropriate constructor for type Microsoft.Exchange.WebServices.Data.OAuthCredentials.
Did you also unblock the Microsoft.IdentityModel.Clients.ActiveDirectory.dll file? Is EWS 2.2 installed on the computer? Please refer to the getting started documentation in the README.
Dear i did unblock the dll. I don't have ews installed in my laptop 😁. Do you have an link to download? Current link is not working.
I can't 100% vouch for this link, but looks like someone reuploaded the install here: https://github.com/gangstanthony/PowerShell/blob/master/EWSManagedAPI2.2.msi
I found it from the Reddit thread below https://www.reddit.com/r/exchangeserver/comments/o9jy3y/looking_for_ewsmanagedapimsi/
Thank you i will check. Else i will add it like an app in Azure.
Maybe its good to do that. Maybe you can write also that in your Readme how to add as azure App.
I think most People will use it. Its just an better and good alternative for Cirasync or Galsync.
Do you also do this aşk schedule task every week?
@nldenic
I think you may be confused about what the Azure app does. Even if you set up an app for this script in Azure, you'll still need to install EWS API 2.2 on the host computer. If you're referring to issue #46, the purpose of the Azure app, in that case, is to circumvent the need for multi-factor authentication.
Personally, I use Windows Task Scheduler to run the script every day.
Thank you i will install that also and let see if thats works.
It will realy be nice if it works in azure without EWS.
Like this option https://practical365.com/prepopulating-outlook-contacts-with-the-graph-api/
Do you think your script will work with gpah api?
@grahamr975
I have now do the following steps: Installed EWS 2.2 on my laptop export my Exchange online admin credentials to an Cred file. Created an bat file with following parrameters : cd "%~dp0EWS-Office365-Contact-Sync" PowerShell.exe -ExecutionPolicy Bypass ^ -File "C:\Users%username%\Desktop\EWS-Office365-Contact-Sync-master\EWSContactSync.ps1" ^ -CredentialPath "C:\Users%username%\Desktop\EWS-Office365-Contact-Sync-master\nldenic.cred" ^ -FolderName "TEST-Contacts" ^ -LogPath "%~dp0Logs" ^ -MailboxList [email protected] ^ -ExcludeSharedMailboxContact ^ -ExcludeContactsWithoutPhoneNumber ^ -ModernAuth ^ pause
Still gettings : ERROR Failed to Sync-ContactList for [email protected] A constructor was not found. Cannot find an appropriate constructor for type Microsoft.Exchange.WebServices.Data.OAuthCredentials.
I have try to disable MFA for my Admin account and run it. But still not working for it.
AD Azure shows me this for my account :
Do you see other issue for this ?
@grahamr975 The problem looks solves for the normal method.
So i have delete -ModernAuth ^ and run my bat file again.
It is working. But does that means my admin account does not have mfa? Because it has mfa active 😁
In the meantime i am still gettinng error for the Azure sollution.
It will be great if you can write the Azure sollution as option.
See also my other qustion #46
@nldenic if the script works without -ModernAuth, that means basic authentication is still enabled within your environment. In order for modern auth to work, you'll need to bypass MFA for the script by trusting the IP of the server you're running the script on. See Microsoft's guide below.
https://docs.microsoft.com/en-us/azure/active-directory/authentication/howto-mfa-adfs#trusted-ips-for-federated-users
@nldenic if the script works without -ModernAuth, that means basic authentication is still enabled within your environment. In order for modern auth to work, you'll need to bypass MFA for the script by trusting the IP of the server you're running the script on. See Microsoft's guide below.
https://docs.microsoft.com/en-us/azure/active-directory/authentication/howto-mfa-adfs#trusted-ips-for-federated-users
Thats correct. For now its working on my account with basicauth. Enabled.
For now this is ok but do you think its simple to make this work with azure api connection? For my its not working yet and get error message see other issue i mention the script there.
@nldenic
If you mean changing the script to not use EWS and only using Azure (Graph API), that would require a rewrite of the majority of the script. It's in the pipeline but not coming soon, since those changes will take time to develop and test.
@grahamr975
For now its working on my on-premise server without the -ModernAuth because this is enabled. For now i am just working on it to let it work with modernauth and using certificate.