skip to Main Content

Connect to Exchange Online PowerShell with ISE using MFA

How to connect to Exchange Online in Office 365 with PowerShell ISE using MFA? The organization enabled MFA and you can’t connect to Exchange Online PowerShell anymore. The good thing is that the organization enabled MFA when using Office 365. The bad thing is that you can’t connect anymore. In this article, you will learn how to connect to  Exchange Online PowerShell with ISE using MFA.

Before you start connecting to Exchange Online PowerShell with ISE

First, go to Programs and Features and make sure that you have Microsoft Exchange Online PowerShell Module installed on the machine. If you don’t have it installed, read the article Connect to Exchange Online PowerShell using MFA. If you have the Exchange Online PowerShell Module installed. Go to the next step.

Connect to Exchange Online PowerShell with ISE using MFA Programs and Features

Connect to Exchange Online PowerShell with ISE using MFA

You need to import the Exchange Online PowerShell module if you want to use PowerShell ISE.

Start PowerShell ISE as administrator. Run two commands. The first will import the Exchange Online PowerShell module. The second will connect to Exchange Online in Office 365.

PS C:\> Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse ).FullName | Select-Object -Last 1)

--------------------------------------------------------------------------
This PowerShell module allows you to connect to Exchange Online service.
To connect, use: Connect-EXOPSSession -UserPrincipalName <your UPN>
This PowerShell module allows you to connect Exchange Online Protection and Security & Compliance Center services also.
To connect, use: Connect-IPPSSession -UserPrincipalName <your UPN>

To get additional information, use: Get-Help Connect-EXOPSSession, or Get-Help Connect-IPPSSession
--------------------------------------------------------------------------

PS C:\> Connect-EXOPSSession -UserPrincipalName admin@alitajran.com

In the sign-in window that opens, enter your password, and then click Sign in.

Connect to Exchange Online PowerShell with ISE using MFA enter password

A verification code is generated and delivered based on the verification response option that’s configured for your account (for example, a text message or the Azure Authenticator app on your mobile phone).

In the verification window that opens, enter the verification code, and then click Verify.

Connect to Exchange Online PowerShell with ISE using MFA enter code

After the verification succeeds, you will get back to the PowerShell window.

How do you know that the connection to Exchange Online PowerShell worked?

Run the Get-Mailbox cmdlet as shown in the previous step. You will see a list of all the mailboxes in Office 365.

PS C:\> Get-Mailbox

Name                      Alias           Database                       ProhibitSendQuota    ExternalDirectoryObjectId
----                      -----           --------                       -----------------    -------------------------
Abigail	Poole             ABPO            EURPR05DG198-db061             99 GB (106,300,44... 5bb4e521-6982-4966-b68b-5a39eda62e11
Jonathan Springer         JOSP            EURPR05DG268-db022             99 GB (106,300,44... 99925238-91a5-4a21-aaf6-86fe9b3fc2b9
DiscoverySearchMailbox... DiscoverySea... EURPR05DG110-db002             50 GB (53,687,091...
Rose White                ROWH            EURPR05DG127-db109             99 GB (106,300,44... dce99q09-d94a-40ba-b55a-f1b99266b5b1
Pippa Robertson           PIRO            EURPR05DG133-db042             99 GB (106,300,44... 1fcc8b49-7566-4c51-97cb-8b08bfdef760
Sean Peters               SEPE            EURPR05DG054-db077             99 GB (106,300,44... 51f7c339-a566-40d1-ae45-13081cfda8d9
Yvonne Knox               YVKN            EURPR05DG122-db035             99 GB (106,300,44... b8e27c18-20ce-4672-9aff-60fdfcf9c097
Charles Reid              CHRE            EURPR05DG237-db072             99 GB (106,300,44... 723c4877-ceeb-4797-8fa7-68629b6be1ea
Edward Johnston           EDJO            EURPR05DG197-db005             99 GB (106,300,44... 8fc787b3-0282-47ae-88b2-ea62e4fa0575
Zoe Abraham               ZOAB            EURPR05DG280-db014             99 GB (106,300,44... 1af8014d-571c-44be-926b-75377fec2b24
Brandon Glover            BRGL            EURPR05DG298-db024             99 GB (106,300,44... 290fc321-aaf4-4c11-b0f1-7ae4855ba5a6

Sign out from PowerShell Online when you are finished

Be sure to disconnect the remote PowerShell session when you’re finished. If you close the Exchange Online PowerShell Module window without disconnecting the session, you could use up all the remote PowerShell sessions available to you, and you’ll need to wait for the sessions to expire.

PS C:\> Get-PSSession | Remove-PSSession

Conclusion

In this article, you learned how to connect to Exchange Online PowerShell with ISE using MFA. Make sure that the Exchange Online PowerShell Module is installed. After that, connect to Exchange Online in Office 365 with ISE using MFA. Did you enjoy this article? You may also like Get disk free space with PowerShell. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top