5 minutes to read
The Exchange Online PowerShell V2 module (abbreviated as the EXO V2 module) uses modern authentication and works with multi-factor authentication (MFA) for connecting to all Exchange-related PowerShell environments in Microsoft 365: Exchange Online PowerShell, Security & Compliance PowerShell, and standalone Exchange Online Protection (EOP) PowerShell. For more information about the EXO V2 module, see About the Exchange Online PowerShell V2 module.
This topic contains instructions for how to connect to Exchange Online PowerShell using the EXO V2 module with or without MFA.
To use the older, less secure remote PowerShell connection instructions that will eventually be deprecated, see Basic auth – Connect to Exchange Online PowerShell.
To use the older Exchange Online Remote PowerShell Module to connect to Exchange Online PowerShell using MFA, see V1 module – Connect to Exchange Online PowerShell using MFA. Note that this older version of the module will eventually be retired.
Having problems? Ask in the Exchange Online forum.
If your account uses multi-factor authentication, use the steps in this section. Otherwise, skip to the Connect to Exchange Online PowerShell without using MFA section.
Import-Module ExchangeOnlineManagement
2. The command that you need to run uses the following syntax:
Connect-ExchangeOnline -UserPrincipalName <UPN> -ShowProgress $true [-ConnectionUri <URL>] [-AzureADAuthorizationEndPointUri <URL>] [-DelegatedOrganization <String>]
navin@contoso.com
).This example connects to Exchange Online PowerShell in a Microsoft 365 or Microsoft 365 GCC organization:
Connect-ExchangeOnline -UserPrincipalName navin@contoso.com -ShowProgress $true
This example connects to Exchange Online PowerShell in an Office 365 Germany organization:
Connect-ExchangeOnline -UserPrincipalName lukas@fabrikam.de -ShowProgress $true -ConnectionUri https://outlook.office.de/PowerShell-LiveID -AzureADAuthorizationEndPointUri https://login.microsoftonline.de/common
This example connects to Exchange Online PowerShell in a Microsoft GCC High organization:
Connect-ExchangeOnline -UserPrincipalName laura@blueyonderairlines.us -ShowProgress $true -ConnectionUri https://outlook.office365.us/powershell-liveid -AzureADAuthorizationEndPointUri https://login.microsoftonline.us/common
This example connects to Exchange Online PowerShell in a Microsoft 365 DoD organization:
Connect-ExchangeOnline -UserPrincipalName julia@adatum.mil -ShowProgress $true -ConnectionUri https://webmail.apps.mil/powershell-liveid -AzureADAuthorizationEndPointUri https://login.microsoftonline.us/common
This example connects to Exchange Online PowerShell to manage another tenant:
Connect-ExchangeOnline -UserPrincipalName navin@contoso.com -DelegatedOrganization adatum.onmicrosoft.com
For detailed syntax and parameter information, see Connect-ExchangeOnline.
Be sure to disconnect the remote PowerShell session when you’re finished. If you close the Windows PowerShell 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. To disconnect the remote PowerShell session, run the following command.
If your account doesn’t use multi-factor authentication, use the steps in this section.
Import-Module ExchangeOnlineManagement
2. Run the following command:
$UserCredential = Get-Credential
In the Windows PowerShell Credential Request dialog box that appears, type your work or school account and password, and then click OK.
3. The command that you need to run uses the following syntax:
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true [-ConnectionUri <URL>] [-DelegatedOrganization <String>]
Connect to Exchange Online PowerShell in a Microsoft 365 or Microsoft 365 GCC organization:
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true
Connect to Exchange Online PowerShell in an Office 365 Germany organization:
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true -ConnectionUri https://outlook.office.de/powershell-liveid/
Connect to Exchange Online PowerShell in an Office 365 operated by 21Vianet organization:
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true -ConnectionUri https://partner.outlook.cn/PowerShell
Connect to Exchange Online PowerShell in a Microsoft 365 GCC High organization:
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true -ConnectionUri https://outlook.office365.us/powershell-liveid/
Connect to Exchange Online PowerShell in a Microsoft 365 DoD organization:
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true -ConnectionUri https://webmail.apps.mil/powershell-liveid
For detailed syntax and parameter information, see Connect-ExchangeOnline.
Be sure to disconnect the remote PowerShell session when you’re finished. If you close the Windows PowerShell 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. To disconnect the remote PowerShell session, run the following command.PowerShellCopy
Disconnect-ExchangeOnline
The Exchange Online cmdlets are imported into your local Windows PowerShell session and tracked by a progress bar. If you don’t receive any errors, you connected successfully. A quick test is to run an Exchange Online PowerShell cmdlet, for example, Get-Mailbox, and see the results.
If you receive errors, check the following requirements: