You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/connect-to-exchange-online-powershell.md
+16-75Lines changed: 16 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,30 +42,35 @@ To use the older Exchange Online Remote PowerShell Module to connect to Exchange
42
42
> [!TIP]
43
43
> Having problems? Ask in the [Exchange Online](https://go.microsoft.com/fwlink/p/?linkId=267542) forum.
44
44
45
-
## Connect to Exchange Online PowerShell using MFA and modern authentication
45
+
## Connect to Exchange Online PowerShell using modern authentication with or without MFA
46
46
47
-
If your account uses multi-factor authentication, use the steps in this section. Otherwise, skip to the [Connect to Exchange Online PowerShell using modern authentication](#connect-to-exchange-online-powershell-using-modern-authentication) section.
47
+
These connection instructions use modern authentication and work with or without multi-factor authentication (MFA).
48
48
49
-
**Note**: For other sign in methods that are available in PowerShell 7, see the [PowerShell 7 log in experiences](#powershell-7-log-in-experiences) section later in this topic.
49
+
For other sign in methods that are available in PowerShell 7, see the [PowerShell 7 log in experiences](#powershell-7-log-in-experiences) section later in this topic.
50
50
51
51
1. In a PowerShell window, load the EXO V2 module by running the following command:
52
52
53
53
```powershell
54
54
Import-Module ExchangeOnlineManagement
55
55
```
56
56
57
-
**Note**: If you've already [installed the EXO V2 module](exchange-online-powershell-v2.md#install-and-maintain-the-exo-v2-module), the previous command will work as written.
57
+
**Notes**:
58
+
59
+
- If you've already [installed the EXO V2 module](exchange-online-powershell-v2.md#install-and-maintain-the-exo-v2-module), the previous command will work as written.
60
+
- You might be able to skip this step and run **Connect-ExchangeOnline** without loading the module first.
58
61
59
62
2. The command that you need to run uses the following syntax:
-_\<UPN\>_ is your account in user principal name format (for example, `[email protected]`).
66
69
- When you use the _ExchangeEnvironmentName_ parameter, you don't need use the _ConnectionUri_ or _AzureADAuthorizationEndPointUrl_ parameters. For more information, see the parameter descriptions in [Connect-ExchangeOnline](/powershell/module/exchange/connect-exchangeonline).
67
70
- The _DelegatedOrganization_ parameter specifies the customer organization that you want to manage as an authorized Microsoft Partner. For more information, see [Partners](/office365/servicedescriptions/office-365-platform-service-description/partners).
68
71
- If you're behind a proxy server, run this command first: `$ProxyOptions = New-PSSessionOption -ProxyAccessType <Value>`, where \<Value\> is `IEConfig`, `WinHttpConfig`, or `AutoDetect`. Then, use the _PSSessionOption_ parameter with the value `$ProxyOptions`. For more information, see [New-PSSessionOption](/powershell/module/microsoft.powershell.core/new-pssessionoption).
72
+
- You can often omit the _UserPrincipalName_ parameter in the next step to enter both the username and password after you run the **Connect-ExchangeOnline** command. If it doesn't work, then you need to use the _UserPrincipalName_ parameter.
73
+
- If you aren't using MFA, you can often use the _Credential_ parameter instead of the _UserPrincipalName_ parameter. First, run the command `$Credential = Get-Credential`, enter your username and password, and then use the variable name for the _Credential_ parameter (`-Credential $Credential`). If it doesn't work, then you need to use the _UserPrincipalName_ parameter.
69
74
70
75
**This example connects to Exchange Online PowerShell in a Microsoft 365 or Microsoft 365 GCC organization**:
71
76
@@ -97,84 +102,20 @@ If your account uses multi-factor authentication, use the steps in this section.
For detailed syntax and parameter information, see [Connect-ExchangeOnline](/powershell/module/exchange/connect-exchangeonline).
105
+
3. In the sign-in window that opens, enter your password, and then click **Sign in**.
101
106
102
-
> [!NOTE]
103
-
> Be sure to disconnect the remote PowerShell session when you're finished. If you close the 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.
107
+

104
108
105
-
```powershell
106
-
Disconnect-ExchangeOnline
107
-
```
109
+
4.**MFA only**: A verification code is generated and delivered based on the response option that's configured for your account (for example, a text message or the Microsoft Authenticator app on your device).
108
110
109
-
## Connect to Exchange Online PowerShell using modern authentication
111
+
In the verification window that opens, enter the verification code, and then click **Verify**.
110
112
111
-
If your account doesn't use multi-factor authentication, use the steps in this section.
112
-
113
-
**Note**: For other sign in methods that are available in PowerShell 7, see the [PowerShell 7 log in experiences](#powershell-7-log-in-experiences) section later in this topic.
114
-
115
-
1. In a PowerShell window, load the EXO V2 module by running the following command:
116
-
117
-
```powershell
118
-
Import-Module ExchangeOnlineManagement
119
-
```
120
-
121
-
**Note**: If you've already [installed the EXO V2 module](exchange-online-powershell-v2.md#install-and-maintain-the-exo-v2-module), the previous command will work as written.
122
-
123
-
2. Run the following command:
124
-
125
-
> [!NOTE]
126
-
> You can skip this step and omit the _Credential_ parameter in the next step to be prompted to enter the username and password after you run the **Connect-ExchangeOnline** command. If you omit the _Credential_ parameter and include the _UserPrincipalName_ parameter in the next step, you're only prompted to enter the password after you run the **Connect-ExchangeOnline** command.
127
-
128
-
```powershell
129
-
$UserCredential = Get-Credential
130
-
```
131
-
132
-
In the credentials prompt, enter your work or school account and password.
133
-
134
-
3. The last command that you need to run uses the following syntax:
- When you use the _ExchangeEnvironmentName_ parameter, you don't need use the _ConnectionUri_ or _AzureADAuthorizationEndPointUrl_ parameters. For more information, see the parameter descriptions in [Connect-ExchangeOnline](/powershell/module/exchange/connect-exchangeonline).
141
-
- The _DelegatedOrganization_ parameter specifies the customer organization that you want to manage as an authorized Microsoft Partner. For more information, see [Partners](/office365/servicedescriptions/office-365-platform-service-description/partners).
142
-
- If you're behind a proxy server, store the output of the [New-PSSessionOption](/powershell/module/microsoft.powershell.core/new-pssessionoption) cmdlet in a variable (for example, `$ProxyOptions = New-PSSessionOption -ProxyAccessType <Value> [-ProxyAuthentication <Value>] [-ProxyCredential <Value>]`). Then, use the variable (`$ProxyOptions`) as the value for the _PSSessionOption_ parameter.
143
-
144
-
**Connect to Exchange Online PowerShell in a Microsoft 365 or Microsoft 365 GCC organization**:

173
114
174
115
For detailed syntax and parameter information, see [Connect-ExchangeOnline](/powershell/module/exchange/connect-exchangeonline).
175
116
176
117
> [!NOTE]
177
-
> Be sure to disconnect the remote PowerShell session when you're finished. If you close the 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:
118
+
> Be sure to disconnect the remote PowerShell session when you're finished. If you close the 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.
0 commit comments