When executing Restore-VEXItem, I get an error: Restore-VEXItem : Failed to open mailbox: mailboxname@mydomain.net
The credentials I use in $DestCreds variable are of the account that owns mailboxname@mydomain.net and has FullAccess over the mailbox. I gave the account Organization Management, ApplicationImpersonation and Global Administrator roles, but the error still persists.
I see, that you are using basic AUTH for the restore.
Microsoft has started disabling basic auth. Maybe this other M365 Org has Basic Auth disabled, so you won't be able to access any mailbox with Basic Auth.
I tried what you suggested and it worked, but it is interactive, meaning I need to open browser manually and enter the code provided. Then I need to authenticate with user account. Is there a way to do the restores without user intervention? My idea is to create a PowerShell script and to schedule the restores to happen completely automatically.
Yes, we wanted to created a test restore procedure which would run once a month, restore a certain mailbox to another mailbox in another MS365 Organization and then check if the specific items appear in the restored mailbox and report on the results. It is meant to be fully automated.
Thanks.
I talked to my team and they gave me a hint. If you try Example 7 from the provided user guide page, you don't need to use device code authorization. It works in my lab. You need to store the certificate with the private key somewhere on your disk. Your script will use the Certificate for authentication instead of the device login.