Since this question is related to Exchange development, I have added the tag "office-exchange-server-dev" to it.
Thanks for your understanding.
I tested the script in my lab and it works fine for me.
Would it be possible to temporarily enable basic auth for this script to work?
You may use this self-service tool to enable it.
If you have Azure Security Defaults enabled, you may need to first disable it.
And if the manage account has MFA enabled, please also disable it.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.