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/app-only-auth-powershell-v2.md
+94-40Lines changed: 94 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -20,36 +20,65 @@ description: "Learn about using the Exchange Online V2 module in scripts and oth
20
20
# App-only authentication for unattended scripts in the EXO V2 module
21
21
22
22
> [!NOTE]
23
-
> The features and procedures described in this article require version 2.0.3 or later of the EXO V2 module. For instructions on how to install or update to this version of the module, see [Install and maintain the EXO V2 module](exchange-online-powershell-v2.md#install-and-maintain-the-exo-v2-module).
23
+
> The features and procedures described in this article require the following versions of the EXO V2 module:
24
+
>
25
+
> -**Exchange Online PowerShell (Connect-ExchangeOnline)**: Version 2.0.3 or later.
26
+
> -**Security & Compliance Center PowerShell (Connect-IPPSSession)**: Version 2.0.6 Preview5 or later.
27
+
>
28
+
> For instructions on how to install or update the module, see [Install and maintain the EXO V2 module](exchange-online-powershell-v2.md#install-and-maintain-the-exo-v2-module).
24
29
25
-
Auditing and reporting scenarios in Exchange Online often involve scripts that run unattended. In most cases, these unattended scripts access Exchange Online PowerShell using Basic authentication (a username and password). Even when the connection to Exchange Online PowerShell uses modern authentication, the credentials are stored in a local file or a secret vault that's accessed at run-time.
30
+
Auditing and reporting scenarios in Microsoft 365 often involve unattendedscripts in Exchange Online PowerShell and Security & Compliance Center PowerShell. In the past, unattended sign in required you to store the username and password in a local file or in a secret vault that's accessed at run-time. But, as we all know, storing user credentials locally is not a good security practice.
26
31
27
-
Because storing user credentials locally is not a safe practice, we're releasing this feature to support authentication for unattended scripts (automation) scenarios using AzureAD applications and self-signed certificates.
32
+
Certificate based authentication (CBA) or app-only authentication as described in this article supports unattended script and automation scenarios by using Azure AD apps and self-signed certificates.
28
33
29
34
The following examples show how to use the Exchange Online PowerShell V2 module with app-only authentication:
30
35
31
36
> [!IMPORTANT]
32
-
> In the **Connect-ExchangeOnline** commands, be sure to use an `.onmicrosoft.com` domain in the _Organization_ parameter value. Otherwise, you might encounter cryptic permission issues when you run commands in the app context.
37
+
> In the **Connect-** commands, be sure to use an `.onmicrosoft.com` domain for the _Organization_ parameter value. Otherwise, you might encounter cryptic permission issues when you run commands in the app context.
When you use the _CertificateThumbPrint_ parameter, the certificate needs to be installed on the computer where you are running the command. The certificate should be installed in the user certificate store.
When you use the _Certificate_ parameter, the certificate does not need to be installed on the computer where you are running the command. This parameter is applicable for scenarios where the certificate object is stored remotely and fetched at runtime during script execution.
55
84
@@ -58,7 +87,7 @@ The following examples show how to use the Exchange Online PowerShell V2 module
58
87
59
88
## How does it work?
60
89
61
-
The EXO V2 module uses the Active Directory Authentication Library to fetch an app-only token using the application Id, tenant Id (organization), and certificate thumbprint. The application object provisioned inside Azure AD has a Directory Role assigned to it, which is returned in the access token. Exchange Online configures the session RBAC using the directory role information that's available in the token.
90
+
The EXO V2 module uses the Active Directory Authentication Library to fetch an app-only token using the application Id, tenant Id (organization), and certificate thumbprint. The application object provisioned inside Azure AD has a Directory Role assigned to it, which is returned in the access token. The session's role based access control (RBAC) is configured using the directory role information that's available in the token.
62
91
63
92
## Set up app-only authentication
64
93
@@ -68,9 +97,9 @@ For a detailed visual flow about creating applications in Azure AD, see <https:/
68
97
69
98
1. [Register the application in Azure AD](#step-1-register-the-application-in-azure-ad).
70
99
71
-
2.[Assign Exchange Online API permissions to the application](#step-2-assign-api-permissions-to-the-application).
100
+
2. [Assign API permissions to the application](#step-2-assign-api-permissions-to-the-application).
72
101
73
-
An application object has the default permission `User.Read`. For the application object to access Exchange Online resources, it needs to have the Application permission `Exchange.ManageAsApp`.
102
+
An application object has the default permission `User.Read`. For the application object to access resources, it needs to have the Application permission `Exchange.ManageAsApp`.
74
103
75
104
3. [Generate a self-signed certificate](#step-3-generate-a-self-signed-certificate)
76
105
@@ -87,24 +116,14 @@ For a detailed visual flow about creating applications in Azure AD, see <https:/
87
116
88
117
5. [Assign Azure AD roles to the application](#step-5-assign-azure-ad-roles-to-the-application)
89
118
90
-
The application needs to have the appropriate RBAC roles assigned. Because the apps are provisioned in Azure AD, you can use any of the built-in roles. The following roles are supported:
91
-
92
-
- Global administrator
93
-
- Compliance administrator
94
-
- Security reader
95
-
- Security administrator
96
-
- Helpdesk administrator
97
-
- Exchange administrator
98
-
- Global Reader
99
-
100
-
> [!NOTE]
101
-
> The Global administrator and Exchange administrator roles provide the necessary permissions for any Exchange-related tasks, including recipient management and protection features (anti-spam, anti-malware, etc). The Security administrator role doesn't not have the necessary permissions for these same Exchange-related tasks.
119
+
The application needs to have the appropriate RBAC roles assigned. Because the apps are provisioned in Azure AD, you can use any of the supported built-in roles.
102
120
103
121
## Appendix
104
122
105
123
## Step 1: Register the application in Azure AD
106
124
107
-
**Note**: If you encounter problems, check the [required permissions](/azure/active-directory/develop/howto-create-service-principal-portal#required-permissions) to verify that your account can create the identity.
125
+
> [!NOTE]
126
+
> If you encounter problems, check the [required permissions](/azure/active-directory/develop/howto-create-service-principal-portal#required-permissions) to verify that your account can create the identity.
108
127
109
128
1. Open the Azure AD portal at <https://portal.azure.com/>.
110
129
@@ -244,18 +263,35 @@ After you register the certificate with your application, you can use the privat
244
263
245
264
## Step 5: Assign Azure AD roles to the application
246
265
247
-
Azure AD has more than 50 admin roles available. For app-only authentication in Exchange Online, we currently support the previously mentioned roles:
266
+
Azure AD has more than 50 admin roles available. The supported roles are described in the following table:
267
+
268
+
<br>
269
+
270
+
****
271
+
272
+
|Role|Exchange Online PowerShell|Security & Compliance Center PowerShell|
<sup>\*</sup> The Global Administrator and Exchange Administrator roles provide the required permissions for any task in Exchange Online PowerShell. For example:
248
284
249
-
- Global administrator
250
-
- Compliance administrator
251
-
- Security reader
252
-
- Security administrator
253
-
- Helpdesk administrator
254
-
- Exchange administrator
255
-
- Global Reader
285
+
- Recipient management.
286
+
- Security and protection features. For example, anti-spam, anti-malware, anti-phishing, and the associated reports.
287
+
288
+
The Security Administrator role does not have the necessary permissions for those same tasks.
256
289
257
290
For general instructions about assigning roles in Azure AD, see [View and assign administrator roles in Azure Active Directory](/azure/active-directory/roles/manage-roles-portal).
258
291
292
+
> [!NOTE]
293
+
> The following steps are slightly different for Exchange Online PowerShell vs. Security & Compliance Center PowerShell. The steps for both environments are shown. To configure roles for both environments, repeat the steps in this section.
294
+
259
295
1. On the Azure AD portal at <https://portal.azure.com/>, under **Manage Azure Active Directory**, click **View**.
260
296
261
297

@@ -266,11 +302,23 @@ For general instructions about assigning roles in Azure AD, see [View and assign
266
302
267
303
3. On the **Roles and administrators** page that opens, find and select one of the supported roles by _clicking on the name of the role_ (not the check box) in the results.
268
304
269
-

305
+
-**Exchange Online PowerShell**:
306
+
307
+

308
+
309
+
-**Security & Compliance Center PowerShell**:
310
+
311
+

270
312
271
313
4. On the **Assignments** page that opens, click **Add assignments**.
272
314
273
-

315
+
-**Exchange Online PowerShell**:
316
+
317
+

318
+
319
+
-**Security & Compliance Center PowerShell**:
320
+
321
+

274
322
275
323
5. In the **Add assignments** flyout that opens, find and select the app that you created in [Step 1](#step-1-register-the-application-in-azure-ad).
276
324
@@ -280,4 +328,10 @@ For general instructions about assigning roles in Azure AD, see [View and assign
280
328
281
329
6. Back on the **Assignments** page, verify that the app has been assigned to the role.
282
330
283
-

331
+
-**Exchange Online PowerShell**:
332
+
333
+

334
+
335
+
-**Security & Compliance Center PowerShell**:
336
+
337
+

Copy file name to clipboardExpand all lines: exchange/docs-conceptual/basic-auth-connect-to-eop-powershell.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -133,11 +133,11 @@ If you receive errors, check the following requirements:
133
133
134
134
- The account you use to connect to Exchange Online Protection PowerShell must be represented as a [mail user in EOP](/microsoft-365/security/office-365-security/manage-mail-users-in-eop) (created manually or by directory synchronization). If the account is not visible in the Exchange admin center (EAC) as a mail user at **Recipients**\>**Contacts**, you'll receive the following error when you try to connect:
135
135
136
-
> Import-PSSession : Running the Get-Command command in a remote session reported the following error: Processing data for a remote command failed with the following error message: The request for the Windows Remote Shell with ShellId <GUID> failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation.
136
+
> Import-PSSession : Running the Get-Command command in a remote session reported the following error: Processing data for a remote command failed with the following error message: The request for the Windows Remote Shell with ShellId \<GUID\> failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation.
137
137
138
138
- The **New-PSSession** command (Step 2) might fail to connect if your client IP address changes during the connection request. This can happen if your organization uses a source network address translation (SNAT) pool that contains multiple IP addresses. The connection error looks like this:
139
139
140
-
> The request for the Windows Remote Shell with ShellId <ID> failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation.
140
+
> The request for the Windows Remote Shell with ShellId \<ID\> failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation.
141
141
142
142
To fix the issue, use an SNAT pool that contains a single IP address, or force the use of a specific IP address for connections to the Exchange Online Protection PowerShell endpoint.
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/basic-auth-connect-to-scc-powershell.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,7 @@ If you receive errors, check the following requirements:
140
140
141
141
- The **New-PSSession** command (Step 2) might fail to connect if your client IP address changes during the connection request. This can happen if your organization uses a source network address translation (SNAT) pool that contains multiple IP addresses. The connection error looks like this:
142
142
143
-
> The request for the Windows Remote Shell with ShellId <ID> failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation.
143
+
> The request for the Windows Remote Shell with ShellId \<ID\> failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation.
144
144
145
145
To fix the issue, use an SNAT pool that contains a single IP address, or force the use of a specific IP address for connections to the Security & Compliance Center PowerShell endpoint.
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/exchange-management-shell.md
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,12 @@ The Exchange Management Shell also provides a robust and flexible scripting plat
21
21
22
22
To start using the Exchange Management Shell immediately, see the [Exchange Management Shell documentation](#exchange-management-shell-documentation) section later in this article.
23
23
24
+
> [!NOTE]
25
+
> There is no Microsoft-provided module in the PowerShell Gallery for Exchange Server PowerShell. Instead, to use PowerShell in Exchange Server, you have the following options:
26
+
>
27
+
> - Use the Exchange Management Shell on an Exchange server or that you've installed locally on your own computer using a **Management tools** only installation of Exchange server. For more information, see [Install the Exchange Server Management Tools](/Exchange/plan-and-deploy/post-installation-tasks/install-management-tools) and [Open the Exchange Management Shell](open-the-exchange-management-shell.md).
28
+
> - Use remote PowerShell from a Windows PowerShell session. For more information, see [Connect to Exchange servers using remote PowerShell](connect-to-exchange-servers-using-remote-powershell.md).
29
+
24
30
## How the Exchange Management Shell works on all Exchange server roles except Edge Transport
25
31
26
32
Whether you use the Exchange Management Shell on a local Exchange server or on an Exchange server that's located across the country, remote PowerShell does the work.
0 commit comments