Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

You cannot have full control of your Office 365 tenant, if you do not know how to use PowerShell for Office 365, since there are a ton of configurations, and settings that are only configurable via PowerShell, and not via the Office 365 Admin Center! Not to mention, all the automation capabilities that PowerShell allows you to script, so you save time and money. Since most accounts admin accounts are (or should be) configured with Multi Factor Authentication, here is a small guide on how to connect to all the Office 365 services with PowerShell and Multi Factor Authentication enabled!

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Azure Active Directory

Once you have the Azure Active Directory module installed, connecting with Multi Factor Authentication is done by specifying the AccountId parameter, and not a full credential object as we would do with single factor authentication. This will Open up a window, asking you to enter the password for that account, and then your second authentication method as seen below.

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

SharePoint Online

When we connect to SharePoint Online using PowerShell, we use the Connect-SPOService cmdlet as usual as well as the URL parameter, which is the URL of your SharePoint Online Admin Center, and simply skip specifying the -Credentials parameter. This will open a pop-up window asking for our credentials, as well as the second method of Authentication as you can see below!

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Exchange Online

While the previous two were easy, this one is a bit more complicated since we need to download a module, whereas to connect with Single Factor Authentication there is nothing to download! From the Exchange Online Admin Center, go to the Hybrid section, and click on Configure under the Exchange Online PowerShell module.

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

You need to do this with Internet Explorer, or else you will be getting a beautiful “Application Cannot Be Started” error as we talked about in this blog! Exchange Online PowerShell Module Error: Application Cannot be Started – Contact the Application Vendor

Once you have the Exchange Online Module, you need to use the Connect-EXOPSSession PowerShell cmdlet, and specify the user account that you will be connecting with.

 

If you are in Office 365 Germany, you need to provide a few more parameters, as seen in the following example.

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Office 365 Security and Compliance Center

To connect to the Office 365 Security and Compliance Center with Multi Factor Authentication, you need the same PowerShell module as Exchange Online, about which we talked earlier, but you will be using the Connect-IPPSSession PowerShell cmdlet as seen in the following example.

If you are part of Office 365 Germany, you will need to provide the additional parameters seen below.

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Skype for Business

To connect to Skype for Business Online using Multi Factor Authentication , you need to use the New-CSOnlineSession PowerShell cmdlet

 

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Microsoft Teams

To Connect to Microsoft Teams, you use the Connect-MicrosoftTeams PowerShell cmdlet, and specify the -AccountID parameter. Similar to the other services, you will get a prompt asking you to input your password, and second method of authentication.

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

Connecting to all Office 365 Services with PowerShell and Multi Factor Authentication

That is it, we have now looked at how to connect to all Office 365 Services, using PowerShell and Multi Factor Authentication!

Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.
5/5 (4)

Please rate this

 
Comments

If we have MFA, do we have to download the module from the Admin Center every time we want to login? I have done this before and it no longer works, so I’m thinking I may need to do it again.

In theory you shouldn’t have to.. it should be “installed” and visible from your apps in the start menu!

Cliff Fernandes

Company uses MFA. I have been given a SharePoint Admin account by global admin. Does the account need to be configured to use MFA? And also my company laptop is 32bit Windows 7 SP1. Do I need to install the 32bit SharePoint Management Shell even though it’s not supported by Microsoft for scripts to work?

Leave a Reply