This script is a modified version of OfficeDev/O365-InvestigationTooling, tailored to support OAuth authentication.
- Navigate to the Azure Portal and select "App registrations" -> "New registration" to create a new application.
- Within the new application, navigate to "API permissions" -> "Add a permission" -> "Office 365 Exchange Online" -> "Application permissions" and select
full_access_as_app
. Then, click on "Add permissions". - Use a Global Admin account to grant admin consent for your organization.
- Generate a client secret by navigating to "Certificates & secrets" -> "New client secret".
- Replace
REPLACE_HERE
with the corresponding values obtained in the previous step. - Replace
mailboxes.txt
with the path to the mailbox list file.
$tenantId = "REPLACE_HERE"
$clientId = "REPLACE_HERE"
$clientSecret = "REPLACE_HERE"
$scope = "https://outlook.office.com/.default"
$listMailboxes = "mailboxes.txt"
- Open PowerShell and execute the script.