David-Barrett-MS / PowerShell-EWS-Scripts

A collection of PowerShell scripts that use EWS to perform actions against Exchange mailboxes
MIT License
118 stars 13 forks source link

full_access_as_app missing #47

Closed T3ST3RZ closed 7 months ago

T3ST3RZ commented 7 months ago

Hi David,

I've used the Merge-Mailbox script without issues when using API Delegated Permissions EWS.AccessAsUser.All.

This is fine for processing individual mailboxes, however i need to loop and process several mailboxes, this means it will auth on each mailbox, i understand that from another issue post you replied on means I'll have to switch to app auth.

When i've tried to do this it appears that i can't find 'full_access_as_app' in the list of the available API's, and when i edit the manifest file, it doesn't recognise it as an app (just displays the ID reference).

Does this mean the full_access_as_app has been deprecated and this script can no longer be ran using app auth?

This is the error i get when running the following

.\Merge-MailboxFolder.ps1 -SourceMailbox 'mbx@example.onmicrosoft.com' -SourceArchive -ProcessSubfolders -CreateTargetFolder -Office365 -OAuth -OAuthTenantId $tenantId -OAuthClientId $clientId -OAuthSecretKey $secretKey -Impersonate

26/01/2024 10:56:57 [ErrorReported] ERROR (ThrottledFolderBind): Exception calling "Bind" with "3" argument(s): "The request failed. The remote server returned an error: (403) Forbidden." Failed to open source message store (mbx@example.onmicrosoft.com) Please check that you have impersonation permissions

(I've given my account ApplicationImpersonation via an Exchange Online role, but not 100% sure if that error is just linked to full_access_as_app not having API perms?)

Any help would be appreciated, thank you.

David-Barrett-MS commented 7 months ago

I just followed the guide (https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth#configure-for-app-only-authentication) to update the manifest and it worked fine for me. I'm not aware of any deprecation, that shouldn't happen until EWS itself is deprecated in 2026.

T3ST3RZ commented 7 months ago

Thanks for the quick response David.

That's strange, I've just tried again and it worked straight away!... I hate it when things like this happen!

Either way, I've just ran the script with app-auth on a couple of test mailboxes it worked flawlessly.. Thank you so much for a great script 👍