Connect to Office 365 services with multifactor authentication (MFA) and PowerShell

Multifactor authentication (MFA) is an Office 365 security best practice, especially for administrator accounts. The Office 365 portal enforces MFA for accounts that have it enabled, but administrators also use PowerShell to manage Office 365.

To connect to Office 365 services with MFA and PowerShell:

For each of these connections, you are prompted with a dialog box to collect the account user name and password and then an additional dialog box for MFA information, such as a verification code. Here is an example for SharePoint Online:


To experiment with MFA in an Office 365 trial subscription, see Multi-factor authentication for your Office 365 dev/test environment.



To join the CAAB, become a member of the CAAB space in the Microsoft Tech Community and send a quick email to to introduce yourself. Please feel free to include any information about your experience in creating cloud-based solutions with Microsoft products or areas of interest. Join now and add your voice to the cloud adoption discussion that is happening across Microsoft and the industry.

Comments (6)
  1. AIP PowerShell also supports MFA 🙂 The Security and Compliance Center is the last one left, of the ones I use at least.

    1. Joe Davies says:

      Thanks Vasil!

      See the instructions on and use the Connect-AadrmService command to get the “Aadrm Admin Powershell” dialog box, from which you can sign in with MFA.

  2. My Blog says:

    Great post. I was checking continuously this blog and I am impressed!
    Very helpful information particularly the last part :
    ) I care for such information much. I was seeking this particular information for a very long time.
    Thank you and good luck.

  3. Terry Munro says:

    Feel free to use my script – Office 365 Connection Script with MFA – Multi-Factor Authentication

    The script will connect to the following services with MFA (Multi-Factor Authentication) enabled-

    – Exchange Online
    – SharePoint Online
    – Skype for Business Online
    – Azure AD v1.0
    – Azure AD v2.0
    – Azure Resource Manager
    – Azure Rights Manager
    – Exchange Online Protection

    1. Andy says:

      Thank you very much Terry! It’s really helpful.


      how we can relate the MFA module in the existing scripts

Comments are closed.

Skip to main content