Until now, your options for such scenarios were to either use basic authentication or ensure that someone will be available to handle the MFA request.
Another front on which Microsoft is making advances is getting rid of basic authentication, more specifically addressing scenarios where you want to perform some tasks via a scheduled script or workflow that cannot be used with an interactive MFA challenge. Microsoft has been working to address these drawbacks and earlier this year we got the new “V2” module, featuring few REST-based cmdlets, which bring speed and reliability improvements and were subject on our recent webinar. Even the release of PowerShell 7 didn’t bring much change – the remote connectivity method we use to manage Exchange Online objects still reigns, and so do all its well-known drawbacks. PowerShell continues to be the most important tool in the arsenal of IT Pros worldwide, yet little has changed since we made the journey to the cloud.