Office 365 – Connecting to PowerShell with MFA

Problem:

You enable MFA in your organization and now you can’t connect through PowerShell

Solution:

(h/t me)

Referencing the following doc (https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps)

Notes:

  1. Use Internet Explorer when you download and run the app
  2. Once you download and install the app, open up PowerShell (admin mode) and run winrm /quickconfig and hit YES
  3. All PowerShell commands should be run through the new app Microsoft Exchange Online Powershell Module
  4. When you run Connect-EXOPSSession -UserPrincipalName chris@contoso.com you’ll get an error, ignore the error
    1. $UserCredential = Get-Credential
    2. Import-Module MSOnline
    3. Connect-MsolService –Credential $UserCredential

This is for the initial setup, subsequently, I’m not sure which steps to go through.