Connect to Exchange Online PowerShell using MFA

%3CLINGO-SUB%20id%3D%22lingo-sub-779635%22%20slang%3D%22en-US%22%3EConnect%20to%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-779635%22%20slang%3D%22en-US%22%3EHello%20%2C%3CBR%20%2F%3EI%20am%20not%20able%20to%20connect%20to%20exchange%20online%20powershell.could%20you%20please%20help%20on%20this.%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-779635%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-779776%22%20slang%3D%22en-US%22%3ERe%3A%20Connect%20to%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-779776%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F384463%22%20target%3D%22_blank%22%3E%40Pawan2055%3C%2FA%3E%26nbsp%3B%26nbsp%3B%3CBR%20%2F%3EWhat%20version%20of%20Windows%20%3F%3C%2FP%3E%3CP%3EWhat%20is%20the%20Error%20Code%20%3F%3C%2FP%3E%3CP%3ESSO%2FSeamless%20Sign%20on%20enabled%20in%20Azure%20AD%20or%20a%20federated%20environment%20%3F%3CBR%20%2F%3EDo%20you%20have%20the%20necessary%20permissions%20to%20connect%20to%20EXO%20PS%20%3F%3C%2FP%3E%3CP%3EIf%20any%20conditional%20access%20enabled%20in%20your%20org%20via%20Azure%20AD%20%3F%3C%2FP%3E%3CP%3EAny%20firewall%20or%20network%20prohibiting%20connection%20%3F%3C%2FP%3E%3CP%3ENecessary%20ports%20open%20over%20Network%20for%20connection%20unblock%20towards%20EXO%20Public%20Ip's%20%3F%3C%2FP%3E%3CP%3EHave%20you%20tried%20using%20EXO%20PowerShell%20from%20outlook.office.com%2Fecp%20via%20Hybrid%20Tab%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20share%20error%20code%20or%20screenshot%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3EAnkit%20Shukla%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-779792%22%20slang%3D%22en-US%22%3ERe%3A%20Connect%20to%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-779792%22%20slang%3D%22en-US%22%3EUsually%20caused%20from%20using%20old%20Exchange%20Online%20Powershell.%20If%20you%20use%20later%20version%20and%20use%20connect-exosession%20it%20should%20use%20MFA%20no%20problem.%20As%20Ankit%20said%2C%20please%20provide%20more%20details.%20Thanks.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-796672%22%20slang%3D%22en-US%22%3ERe%3A%20Connect%20to%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-796672%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F384463%22%20target%3D%22_blank%22%3E%40Pawan2055%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3BI%20hope%20this%20might%20help%20you%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fo365reports.com%2F2019%2F04%2F17%2Fconnect-exchange-online-using-mfa%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EConnect%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20blog%20explains%20following%20things%3A%3C%2FP%3E%3CUL%3E%3CLI%3EHow%20to%20install%20Exchange%20Online%20PowerShell%20Module%20for%20MFA%3C%2FLI%3E%3CLI%3EHow%20to%20connect%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FLI%3E%3CLI%3ETrouble%20shooting%20tips%20to%20connect%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-817015%22%20slang%3D%22en-US%22%3ERe%3A%20Connect%20to%20Exchange%20Online%20PowerShell%20using%20MFA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-817015%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%20to%20use%20multi-factor%20authentication%20(MFA)%20to%20connect%20to%20Exchange%20Online%20PowerShell%2C%20you%20can't%20use%20the%20instructions%20at%26nbsp%3B%3CU%3EConnect%20to%20Exchange%20Online%20PowerShell%3C%2FU%3E%26nbsp%3Bto%20use%20remote%20PowerShell%20to%20connect%20to%20Exchange%20Online.%3C%2FP%3E%3CUL%3E%3CLI%3EFirst%2C%20MFA%20requires%20you%20to%20install%20the%20Exchange%20Online%20Remote%20PowerShell%20Module%3C%2FLI%3E%3CLI%3EThen%20you%20need%20to%20use%20the%26nbsp%3B%3CSTRONG%3EConnect-EXOPSSession%3C%2FSTRONG%3E%26nbsp%3Bcmdlet%20to%20connect%3C%2FLI%3E%3C%2FUL%3E%3CP%3EOk%2C%20lets%20see%20how%20it%20works%E2%80%A6%3C%2FP%3E%3CUL%3E%3CLI%3EOpen%20the%26nbsp%3B%3CSTRONG%3EExchange%20Online%20Remote%20PowerShell%20Module%3C%2FSTRONG%3E%26nbsp%3B(%26nbsp%3B%3CSTRONG%3EMicrosoft%20Corporation%3C%2FSTRONG%3E%26nbsp%3B%26gt%3B%26nbsp%3B%3CSTRONG%3EMicrosoft%20Exchange%20Online%20Remote%20PowerShell%20Module%3C%2FSTRONG%3E).%3C%2FLI%3E%3CLI%3ERun%20the%20command%2C%26nbsp%3BConnect-EXOPSSession%20%E2%80%93UserPrincipalName%26nbsp%3B%3CU%3Edeva%20%40%20contoso.%20onmicrosoft.%20com%3C%2FU%3E%3C%2FLI%3E%3CLI%3E%3CBR%20%2F%3EThis%20throws%20the%20credentials%20prompt%2C%20so%20provide%20the%20password.%3C%2FLI%3E%3CLI%3EA%20verification%20code%20is%20generated%2C%20sent.%3C%2FLI%3E%3CLI%3EProvide%20the%20verification%20code%20in%20Verification%20window%3C%2FLI%3E%3CLI%3EAfter%20Step%204%2C%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.o365cloudexperts.com%2Fexchange-online-plans%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EExchange%20Online%3C%2FA%3Ecmdlets%20are%20imported%20into%20your%20Exchange%20Online%20Remote%20PowerShell%20Module%20session%20and%20tracked%20by%20a%20progress%20bar.%3C%2FLI%3E%3CLI%3EIf%20you%20don't%20receive%20any%20errors%2C%20you%20connected%20successfully.%3C%2FLI%3E%3C%2FUL%3E%3CUL%3E%3CLI%3EJust%20to%20check%20that%2C%20run%20any%20of%20the%20Exchange%20cmdlet%20and%20see%20the%20results.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EOnce%20you%E2%80%99re%20done%20and%20want%20to%20disconnect%20all%20currently%20open%20PowerShell%20sessions%20in%20the%20current%20window%2C%20run%20the%20following%20command%3A%26nbsp%3BGet-PSSession%20%7C%20Remove-PSSession%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor
Hello ,
I am not able to connect to exchange online powershell.could you please help on this.
4 Replies
Highlighted

@Pawan2055  
What version of Windows ?

What is the Error Code ?

SSO/Seamless Sign on enabled in Azure AD or a federated environment ?
Do you have the necessary permissions to connect to EXO PS ?

If any conditional access enabled in your org via Azure AD ?

Any firewall or network prohibiting connection ?

Necessary ports open over Network for connection unblock towards EXO Public Ip's ?

Have you tried using EXO PowerShell from outlook.office.com/ecp via Hybrid Tab ?

 

Please share error code or screenshot 

 

Cheers

Ankit Shukla

 

Highlighted
Usually caused from using old Exchange Online Powershell. If you use later version and use connect-exosession it should use MFA no problem. As Ankit said, please provide more details. Thanks.
Highlighted

@Pawan2055

 I hope this might help you

Connect Exchange Online PowerShell using MFA

 

This blog explains following things:

  • How to install Exchange Online PowerShell Module for MFA
  • How to connect Exchange Online PowerShell using MFA
  • Trouble shooting tips to connect Exchange Online PowerShell using MFA

 

Highlighted

 

 

If you want to use multi-factor authentication (MFA) to connect to Exchange Online PowerShell, you can't use the instructions at Connect to Exchange Online PowerShell to use remote PowerShell to connect to Exchange Online.

  • First, MFA requires you to install the Exchange Online Remote PowerShell Module
  • Then you need to use the Connect-EXOPSSession cmdlet to connect

Ok, lets see how it works…

  • Open the Exchange Online Remote PowerShell Module ( Microsoft Corporation > Microsoft Exchange Online Remote PowerShell Module).
  • Run the command, Connect-EXOPSSession –UserPrincipalName deva @ contoso. onmicrosoft. com

  • This throws the credentials prompt, so provide the password.
  • A verification code is generated, sent.
  • Provide the verification code in Verification window
  • After Step 4, the Exchange Online cmdlets are imported into your Exchange Online Remote PowerShell Module session and tracked by a progress bar.
  • If you don't receive any errors, you connected successfully.
  • Just to check that, run any of the Exchange cmdlet and see the results.

 

  • Once you’re done and want to disconnect all currently open PowerShell sessions in the current window, run the following command: Get-PSSession | Remove-PSSession

 

Hope this helps.