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
+69-19Lines changed: 69 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,10 @@ To use the older Exchange Online Remote PowerShell Module to connect to Exchange
27
27
28
28
## What do you need to know before you begin?
29
29
30
-
- The requirements for installing and using the EXO V2 module are described in [Install and maintain the EXO V2 module](exchange-online-powershell-v2.md#install-and-maintain-the-exo-v2-module). The rest of the instructions in the article assume that you've already installed the module.
30
+
- The requirements for installing and using the EXO V2 module are described in [Install and maintain the EXO V2 module](exchange-online-powershell-v2.md#install-and-maintain-the-exo-v2-module).
31
+
32
+
> [!NOTE]
33
+
> The rest of the instructions in the article assume that you've already installed the module.
31
34
32
35
- After you connect, the cmdlets and parameters that you have or don't have access to is controlled by role-based access control (RBAC). For more information, see [Permissions in Exchange Online](https://docs.microsoft.com/exchange/permissions-exo/permissions-exo).
33
36
@@ -40,7 +43,9 @@ To use the older Exchange Online Remote PowerShell Module to connect to Exchange
40
43
41
44
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.
42
45
43
-
1. In a Windows PowerShell window, load the EXO V2 module by running the following command:
46
+
**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.
47
+
48
+
1. In a PowerShell window, load the EXO V2 module by running the following command:
44
49
45
50
```powershell
46
51
Import-Module ExchangeOnlineManagement
@@ -51,48 +56,49 @@ If your account uses multi-factor authentication, use the steps in this section.
51
56
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]`).
58
63
- 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](https://docs.microsoft.com/powershell/module/exchange/connect-exchangeonline).
59
64
- The _DelegatedOrganization_ parameter specifies the customer organization that you want to manage as an authorized Microsoft Partner. For more information, see [Partners](https://docs.microsoft.com/office365/servicedescriptions/office-365-platform-service-description/partners).
60
65
- 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](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/new-pssessionoption).
66
+
- The progress bar is now shown by default, so `-ShowProgress $true` is no longer required. To hide the progress bar, use this exact syntax: `-ShowProgress:$false`.
61
67
62
68
**This example connects to Exchange Online PowerShell in a Microsoft 365 or Microsoft 365 GCC organization**:
For detailed syntax and parameter information, see [Connect-ExchangeOnline](https://docs.microsoft.com/powershell/module/exchange/connect-exchangeonline).
93
99
94
100
> [!NOTE]
95
-
> 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.
101
+
> 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.
96
102
97
103
```powershell
98
104
Disconnect-ExchangeOnline
@@ -102,7 +108,9 @@ Disconnect-ExchangeOnline
102
108
103
109
If your account doesn't use multi-factor authentication, use the steps in this section.
104
110
105
-
1. In a Windows PowerShell window, load the EXO V2 module by running the following command:
111
+
**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.
112
+
113
+
1. In a PowerShell window, load the EXO V2 module by running the following command:
106
114
107
115
```powershell
108
116
Import-Module ExchangeOnlineManagement
@@ -119,60 +127,102 @@ If your account doesn't use multi-factor authentication, use the steps in this s
119
127
$UserCredential = Get-Credential
120
128
```
121
129
122
-
In the **Windows PowerShell Credential Request** dialog box that appears, type your work or school account and password, and then click **OK**.
130
+
In the credentials prompt, enter your work or school account and password.
123
131
124
132
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](https://docs.microsoft.com/powershell/module/exchange/connect-exchangeonline).
131
139
- The _DelegatedOrganization_ parameter specifies the customer organization that you want to manage as an authorized Microsoft Partner. For more information, see [Partners](https://docs.microsoft.com/office365/servicedescriptions/office-365-platform-service-description/partners).
132
140
- If you're behind a proxy server, store the output of the [New-PSSessionOption](https://docs.microsoft.com/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.
141
+
- The progress bar is now shown by default, so `-ShowProgress $true` is no longer required. To hide the progress bar, use this exact syntax: `-ShowProgress:$false`.
133
142
134
143
**Connect to Exchange Online PowerShell in a Microsoft 365 or Microsoft 365 GCC organization**:
For detailed syntax and parameter information, see [Connect-ExchangeOnline](https://docs.microsoft.com/powershell/module/exchange/connect-exchangeonline).
165
174
166
175
> [!NOTE]
167
-
> 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:
176
+
> 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:
168
177
169
178
```powershell
170
179
Disconnect-ExchangeOnline
171
180
```
172
181
182
+
## PowerShell 7 log in experiences
183
+
184
+
This section describes the log in experiences that are available in version 2.0.4 or later of the EXO V2 module in PowerShell 7.
185
+
186
+
For more information about the operating systems that are supported by the EXO V2 module in PowerShell 7, see [Supported operating systems for the EXO V2 module](exchange-online-powershell-v2.md#supported-operating-systems-for-the-exo-v2-module).
187
+
188
+
For detailed syntax and parameter information, see [Connect-ExchangeOnline](https://docs.microsoft.com/powershell/module/exchange/connect-exchangeonline).
189
+
190
+
### Interactive scripting using browser-based single sign-on
191
+
192
+
Browser-based single sign-on (SSO) is the default log in method in PowerShell 7. The **Connect-ExchangeOnline** command opens the Azure AD login page in the default browser. After you enter your credentials, older Exchange Online cmdlets and EXO V2 module cmdlets are available in the resulting PowerShell session.
193
+
194
+
If you use the _UserPrincipalName_ parameter in the command, the UPN value is used on the login page in the browser.
Use device-based log in when no browser is available (and therefore, you can't see the login page):
203
+
204
+
```powershell
205
+
Connect-ExchangeOnline -Device
206
+
```
207
+
208
+
The command returns a URL and unique code that's tied to the session. You need to open the URL in a browser on any computer, and then enter the unique code. After you complete the login in the web browser, the session in the Powershell 7 window is authenticated via the regular Azure AD authentication flow, and the Exchange Online cmdlets are imported after few seconds.
209
+
210
+
### Inline credentials
211
+
212
+
You can enter your credentials directly in the PowerShell window without the need to go to the browser for SSO.
213
+
214
+
> [!NOTE]
215
+
> This method does not work with accounts that use multi-factor authentication.
216
+
217
+
This method is an improvement on the _Credential_ parameter, because you don't need to store the credentials locally in a script, and you can enter the credentials directly in an interactive PowerShell session.
218
+
219
+
```powershell
220
+
Connect-ExchangeOnline -InlineCredential
221
+
```
222
+
173
223
## How do you know this worked?
174
224
175
-
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.
225
+
The Exchange Online cmdlets are imported into your local 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.
176
226
177
227
If you receive errors, check the following requirements:
0 commit comments