PowerShell-EWS-Scripts icon indicating copy to clipboard operation
PowerShell-EWS-Scripts copied to clipboard

Microsoft 365 Authentication Issue

Open lachlanpatterson opened this issue 3 years ago • 7 comments

It looks like the URL in the script for Microsoft 365 authentication may be out of date. Getting a 404 error when using -Office365 and -OAuth

lachlanpatterson avatar Feb 25 '22 14:02 lachlanpatterson

Which script are you referring to? I've updated the OAuth for several of the scripts but not all. If you can let me know which one I'll check and make the necessary changes.

David-Barrett-MS avatar Feb 25 '22 14:02 David-Barrett-MS

This is for the MergeMailboxFolder.ps1 script. Sorry for not specifying to begin with!

From: David @.> Sent: Friday, February 25, 2022 9:53 AM To: @.> Cc: Lachlan @.>; @.> Subject: Re: [David-Barrett-MS/PowerShell-EWS-Scripts] Microsoft 365 Authentication Issue (Issue #8)

Which script are you referring to? I've updated the OAuth for several of the scripts but not all. If you can let me know which one I'll check and make the necessary changes.

— Reply to this email directly, view it on GitHubhttps://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/issues/8#issuecomment-1050921667, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAO72VKVEQAUMEHOVTIDMTTU46JWZANCNFSM5PKONMZA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>

lachlanpatterson avatar Feb 25 '22 15:02 lachlanpatterson

Interesting, as that is one of the scripts that is up-to-date. However, the log-in URL is determined by your tenant Id, so you need to ensure that is passed - you can't just use the -OAuth switch, you'll need to provide the other OAuth information too (minimum required would be tenant Id, but you may also need to set some of the other OAuth parameters).

David-Barrett-MS avatar Feb 25 '22 15:02 David-Barrett-MS

I think I see now. I'll take a closer look. Thanks!

From: David @.> Sent: Friday, February 25, 2022 10:50 AM To: @.> Cc: Lachlan @.>; @.> Subject: Re: [David-Barrett-MS/PowerShell-EWS-Scripts] Microsoft 365 Authentication Issue (Issue #8)

Interesting, as that is one of the scripts that is up-to-date. However, the log-in URL is determined by your tenant Id, so you need to ensure that is passed - you can't just use the -OAuth switch, you'll need to provide the other OAuth information too (minimum required would be tenant Id, but you may also need to set some of the other OAuth parameters).

— Reply to this email directly, view it on GitHubhttps://github.com/David-Barrett-MS/PowerShell-EWS-Scripts/issues/8#issuecomment-1050970732, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAO72VPNSSFVYFUIYSL6KBDU46QNBANCNFSM5PKONMZA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>

lachlanpatterson avatar Feb 25 '22 16:02 lachlanpatterson

Hello David, Thnks for all of these scripts, that I try to understand. My goal is to use Create-MailboxFolder script, with MFA. I'm trying this one MergeMailboxFolder, and does not understand.

If I try this one: .\Merge-MailboxFolder.ps1 -SourceMailbox [email protected] -SourceArchive -MergeFolderList @{"TESTMERGE" = "TESTMERGE"} -Office365 -OAuth -OAuthTenantId c93fa772-c086-4e1f-9dc2-f71b37148556

... I can see redirect to localhost URI. Do I need to prevent this? Thanks

knut1er avatar Aug 16 '22 13:08 knut1er

The OAuth settings must all come from your own tenant registration. You need to register the OAuth application in the Azure portal, per this guide: https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth

You can then pass in the relevant details to the script using the OAuth parameters.

I will add some more guides when I get a chance to cover common scenarios and give more context to the existing examples.

David-Barrett-MS avatar Aug 22 '22 15:08 David-Barrett-MS

Hi David,

First of all, thanks for all the work you have put into these amazing scripts. As for myself I manage to create powershell scripts to analyse mailboxes and ease the process of troubleshooting. On the other hand, EWS i'm struggling a bit.

For that mather, some years ago, I found a usefull script of yours for deleting empty folders in users mailboxes thru applicationimpersonation. Your script was called: Search-EmptyFolders.ps1 which is now get-emptyfolders.ps1. Extremely handy when Archiving was setup for a user and all those folders remained empty in the mailbox still causing preformance issues in Outlook.

Had problems with Basic Auth on tenants now. Found your get-emptyfolders.ps1 as a new version but does it support oauth?

Kevin-Netflow avatar Sep 03 '22 08:09 Kevin-Netflow

Get-EmptyFolders.ps1 does not support OAuth. I'll add it when I get the chance. I've opened a new issue to track that.

David-Barrett-MS avatar Nov 30 '22 16:11 David-Barrett-MS