A cloud-based identity and access management service for securing user authentication and resource access
The Graph API and the latest versions of the PowerShell modules across various M365 workloads all support Modern auth. If you want a fully automated solution, use certificate-based authentication, or obtain/pass tokens in the application context. Here's an example of how Exchange Online leverages CBA: https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps