Search code examples
powershellmulti-factor-authenticationmicrosoft365

How do I do authentication for my powershell scripts for Microsoft 365/AzureAD/Exchange Online automation?


So I can successfully run commands to manage our Microsoft 365/AzureAd/Exchange Online - this involves assigning and removing license, converting user to a shared mailbox, delegating access to a mailbox, etc. I followed the guide here for authentication. But that's me actually logging in with my credentials + MFA (Multi-factor authentication) for authentication.

I want to have a script that does these type of actions triggered by a schedule. I believe I can include the credentials but how to do MFA? Tried to follow this but getting error clientid is not a guid I have registered an app in https://portal.azure.com/ and able to do Graph API calls using that. No luck in PowerShell authentication though. Any thoughts? Thanks!


Solution

  • This is not possible. A potential solution is to set some rules where in specific case, MFA will not be required.