
As many organizations enabled MFA (Multi Factor Authentication) with their Microsoft 365 subscriptions for extra security, company administrators or global administrators can no longer use classic login method of remote PowerShell. The following is a small guidance steps on how to connect to all Microsoft 365 services with PowerShell and MFA enabled.
You will need to make sure that you already installed MSOnline module in your system. If not, here is the steps to install it. You only need to do this once.
- On your local computer, open Windows PowerShell with elevated permission. Then type the following
Install-Module -Name MSOnline

- Confirm the prompts to Y (yes)


- Once it’s installed, then you are ready to connect to Microsoft 365 services. Type the command below
Import-Module MsOnline

- The next command is
Connect-MsolService

- This will launch Microsoft 365 prompt window requesting to enter your administrator credentials

- Once you have entered your administrator credential, it will ask to approve or enter temporary login code depending the type of MFA your organization has selected

- Once it’s authenticated, then type in the following command – please use your own UPN in place of youremailaddress@yourdomain.com
Connect-ExchangeOnline -UserPrincipalName youremailaddress@yourdomain.com

- Once it’s connect command is loaded, you are now ready to manage your organization Microsoft 365 services

- Make sure you disconnect your remote session once you finished your tasks by typing the following command
Disconnect-ExchangeOnline

- Select Y (yes) to close your session
