If you want to use multi-factor authentication (MFA) to connect to Exchange Online PowerShell, you can't use the instructions at Connect to Exchange Online PowerShell to use remote PowerShell to connect to Exchange Online.
- First, MFA requires you to install the Exchange Online Remote PowerShell Module
- Then you need to use the Connect-EXOPSSession cmdlet to connect
Ok, lets see how it works…
- Before you do this, make sure you tried as given here.
- Open the Exchange Online Remote PowerShell Module ( Microsoft Corporation > Microsoft Exchange Online Remote PowerShell Module).
- Run the command,
Connect-EXOPSSession –UserPrincipalName email@example.com
This throws the credentials prompt, so provide the password.
A verification code is generated, sent.
Provide the verification code in Verification window
- After Step 4, the Exchange Online cmdlets are imported into your Exchange Online Remote PowerShell Module session and tracked by a progress bar.
- If you don't receive any errors, you connected successfully.
- Just to check that, run any of the Exchange cmdlet and see the results.
Get-PSSession | Remove-PSSession
Hope this helps.