Use a cert or even better, a managed identity and Azure automation:
https://office365itpros.com/2025/02/10/azure-automation-exchange-primer/
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I’m trying to streamline some admin workflows by running a set of automated scripts against Exchange Online, but I’m not fully sure what the safest and most reliable way is to configure PowerShell for these tasks. I’m currently using the Exchange Online PowerShell V3 module (Connect-ExchangeOnline), but I’m unsure whether I should rely on interactive sign-in, App-Only authentication, or a registered Azure AD application with certificate-based auth.
How should I properly set up Exchange Online PowerShell so that scheduled or unattended scripts can authenticate securely
Use a cert or even better, a managed identity and Azure automation:
https://office365itpros.com/2025/02/10/azure-automation-exchange-primer/
To securely set up Exchange Online PowerShell for automated admin tasks, you should consider using App-Only authentication with certificate-based authentication. This method allows you to run unattended scripts without the need for interactive sign-in, making it ideal for scheduled tasks.
Here are the steps to configure it:
Exchange.ManageAsApp permission. Grant admin consent for this permission.Connect-ExchangeOnline command with the appropriate parameters, including the path to your certificate and the application ID. Here’s an example command:
Connect-ExchangeOnline -CertificateFilePath "C:\path\to\automation-cert.pfx" -CertificatePassword (Get-Credential).password -AppID "your-app-id" -Organization "your-organization.onmicrosoft.com"
By following these steps, you can securely automate your Exchange Online administrative tasks without compromising security or requiring manual intervention.