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

Script stopped working #22

Closed dmaglinte77 closed 1 year ago

dmaglinte77 commented 3 years ago

This script stopped working for me at the end of september. MFA has been enabled in our tenant, but the user that I'm using to for the script has been excluded. But no matter what I do I cannot seem to get the script to work. Has anyone else seen this issue? Capture

grahamr975 commented 3 years ago

Are you sure that the user is excluded? That portion of the script doesn't depend on application impersonation or EWS. I'd suggest you double-check the credentials. You can test by manually running the below code in a PowerShell window. It should return a list of all users.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $ConnectionUri -Credential Get-Credential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking -AllowClobber

        # Import Global Address List into Powershell from Office 365 Exchange as an array
        $ContactList = Get-User -ResultSize unlimited
dmaglinte77 commented 3 years ago

It’s erroring out. Here’s the error message:

[cid:image002.jpg@01D6B38A.225F54A0]

From: Ryan Graham notifications@github.com Sent: Thursday, November 5, 2020 3:38 PM To: grahamr975/EWS-Office365-Contact-Sync EWS-Office365-Contact-Sync@noreply.github.com Cc: Dino Maglinte DMaglinte@ChoicesCCS.org; Author author@noreply.github.com Subject: Re: [grahamr975/EWS-Office365-Contact-Sync] Script stopped working (#22)

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Are you sure that the user is excluded? That portion of the script doesn't use application impersonation or EWS. I'd suggest you double-check the credentials. You can test by manually running the below code in a PowerShell window.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $ConnectionUri -Credential Get-Credential -Authentication Basic -AllowRedirection

Import-PSSession $Session -DisableNameChecking -AllowClobber

           # Import Global Address List into Powershell from Office 365 Exchange as an array

           $ContactList = Get-User -ResultSize unlimited

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/grahamr975/EWS-Office365-Contact-Sync/issues/22#issuecomment-722629823, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQWKRCW2ANX3CLNOWLCCBH3SOMEIXANCNFSM4TJIDUNA.

grahamr975 commented 3 years ago

@dmaglinte77 I don't see the error message?

dmaglinte77 commented 3 years ago

ScriptError

grahamr975 commented 3 years ago

Yep, definitely looks like an authentication issue with the account you're using. Could be one or more of the below issues:

  1. Invalid username/password
  2. Basic authentication is disabled in your environment
  3. The account lacks Exchange Online admin access

I'd suggest you follow Microsoft's troubleshooting guide here and verify that basic authentication is enabled for the account.

dmaglinte77 commented 3 years ago

Good morning! I was able to make some progress. I had to go into the MFA settings inside Org Settings and allow Exchange Online Powershell to use Basic Auth. But now I'm getting different errorS:

PS>TerminatingError(Connect-EXCExchange): "Exception calling "AutodiscoverUrl" with "2" argument(s): "The Autodiscover service couldn't be located.""

TerminatingError(Connect-EXCExchange): "Exception calling "AutodiscoverUrl" with "2" argument(s): "The Autodiscover service couldn't be located."" 2020/11/06 10:57:08 ERROR Failed to Sync-ContactList for 12345@12345.org Exception calling "AutodiscoverUrl" with "2" argument(s): "The Autodiscover service couldn't be located."

grahamr975 commented 3 years ago

Looks like you're using basic EWS authentication (Negotiate Auth), which your environment is probably also blocking. Can you try using the latest version of the script along with the -ModernAuth flag? Make sure to follow the new instructions found in the read me.

dmaglinte77 commented 3 years ago

No dice. I re-downloaded your code and ran it again. Made sure -ModernAuth was set, but still getting that same error message.

grahamr975 commented 1 year ago

@dmaglinte77 The newest version of the script now uses an AzureApp so it completely bypasses MFA-related issues. Please update and follow the guide in the README.md to resolve this issue.

dmaglinte77 commented 1 year ago

Will the old script still work or do we need to immediately start using this new version?

From: Ryan Graham @.> Sent: Thursday, September 15, 2022 9:55 AM To: grahamr975/EWS-Office365-Contact-Sync @.> Cc: Dino Maglinte @.>; Mention @.> Subject: Re: [grahamr975/EWS-Office365-Contact-Sync] Script stopped working (#22)

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Closed #22https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgrahamr975%2FEWS-Office365-Contact-Sync%2Fissues%2F22&data=05%7C01%7Cdmaglinte%40choicesccs.org%7Cf0b9bdfd3dda4876b8f308da9721dfd9%7C9baed786d7bf4ec2a449f58458b98ffc%7C0%7C0%7C637988469011149947%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5rCmRy9fle6YhNl24%2Bk9ZSK8ZpQbQga6VnxodKaJ8u0%3D&reserved=0 as completed.

- Reply to this email directly, view it on GitHubhttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgrahamr975%2FEWS-Office365-Contact-Sync%2Fissues%2F22%23event-7395255541&data=05%7C01%7Cdmaglinte%40choicesccs.org%7Cf0b9bdfd3dda4876b8f308da9721dfd9%7C9baed786d7bf4ec2a449f58458b98ffc%7C0%7C0%7C637988469011149947%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4uNhghWEVNwk53xszwsxpa4pMbr%2BjGTRYemCFo4qma0%3D&reserved=0, or unsubscribehttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQWKRCQBP4DWU7HEH2WLOQLV6MTDBANCNFSM4TJIDUNA&data=05%7C01%7Cdmaglinte%40choicesccs.org%7Cf0b9bdfd3dda4876b8f308da9721dfd9%7C9baed786d7bf4ec2a449f58458b98ffc%7C0%7C0%7C637988469011149947%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ewDMglGV3X6j7Mgq4%2BS%2FLzHz%2BFios9ANFC0NLXa45DA%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

grahamr975 commented 1 year ago

@dmaglinte77

I'd recommend updating soon.

Microsoft will depreciate basic authentication (used by the old script) on October 1st, 2022. Tenets will have the opportunity to manually delay the depreciation until December 31st, 2022 on a per-protocol basis. See below.

https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-deprecation-in-exchange-online-september/ba-p/3609437