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
Updated the documentation for app-only authentication in Exchange Online PowerShell to improve clarity and accuracy regarding version requirements and other details.
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/app-only-auth-powershell-v2.md
+29-28Lines changed: 29 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,24 +19,25 @@ description: "Learn how to configure app-only authentication (also known as cert
19
19
20
20
# App-only authentication for unattended scripts in Exchange Online PowerShell and Security & Compliance PowerShell
21
21
22
-
Auditing and reporting scenarios in Microsoft 365 often involve unattended scripts in Exchange Online PowerShell and Security & Compliance 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 isn't a good security practice.
22
+
Auditing and reporting scenarios in Microsoft 365 often involve unattended scripts in Exchange Online PowerShell and Security & Compliance PowerShell. In the past, unattended sign in required you to store the username and password in a local file or in a secret vault accessed at run-time. But, as we all know, storing user credentials locally isn't a good security practice.
23
23
24
24
Certificate based authentication (CBA) or app-only authentication as described in this article supports unattended script and automation scenarios by using Microsoft Entra apps and self-signed certificates.
25
25
26
26
> [!NOTE]
27
+
>
27
28
> - Did you know that you can connect to Exchange Online PowerShell using managed identities in Azure? Check out [Use Azure managed identities to connect to Exchange Online PowerShell](connect-exo-powershell-managed-identity.md).
28
29
>
29
30
> - The features and procedures described in this article require the following versions of the Exchange Online PowerShell module:
30
-
> -**Exchange Online PowerShell (Connect-ExchangeOnline)**: Version 2.0.3 or later.
31
-
> -**Security & Compliance PowerShell (Connect-IPPSSession)**: Version 3.0.0 or later.
31
+
> -**Exchange Online PowerShell (Connect-ExchangeOnline)**: Version 2.0.4 or later.
32
+
> -**Security & Compliance PowerShell (Connect-IPPSSession)**: Version 3.0.0 or later.
32
33
>
33
-
> For instructions on how to install or update the module, see [Install and maintain the Exchange Online PowerShell module](exchange-online-powershell-v2.md#install-and-maintain-the-exchange-online-powershell-module). For instructions on how to use the module in Azure automation, see [Manage modules in Azure Automation](/azure/automation/shared-resources/modules).
34
+
> For instructions on how to install or update the module, see [Install and maintain the Exchange Online PowerShell module](exchange-online-powershell-v2.md#install-and-maintain-the-exchange-online-powershell-module). For instructions on how to use the module in Azure Automation, see [Manage modules in Azure Automation](/azure/automation/shared-resources/modules).
34
35
>
35
36
> - CBA or app-only authentication is available in Office 365 operated by 21Vianet in China.
36
37
>
37
38
> - REST API connections in the Exchange Online PowerShell V3 module require the PowerShellGet and PackageManagement modules. For more information, see [PowerShellGet for REST-based connections in Windows](exchange-online-powershell-v2.md#powershellget-for-rest-api-connections-in-windows).
38
39
>
39
-
> If the procedures in this article don't work for you, verify that you don't have Beta versions of the PackageManagement or PowerShellGet modules installed by running the following command: `Get-InstalledModule PackageManagement -AllVersions; Get-InstalledModule PowerShellGet -AllVersions`.
40
+
> If the procedures in this article don't work for you, verify that you don't have preview versions of the PackageManagement or PowerShellGet modules installed by running the following command: `Get-InstalledModule PackageManagement -AllVersions; Get-InstalledModule PowerShellGet -AllVersions`.
40
41
>
41
42
> - In Exchange Online PowerShell, you can't use the procedures in this article with the following Microsoft 365 Group cmdlets:
@@ -47,12 +48,12 @@ Certificate based authentication (CBA) or app-only authentication as described i
47
48
> You can use Microsoft Graph to replace most of the functionality from those cmdlets. For more information, see [Working with groups in Microsoft Graph](/graph/api/resources/groups-overview).
48
49
>
49
50
> - In Security & Compliance PowerShell, you can't use the procedures in this article with the following Microsoft Purview cmdlets:
> - Delegated scenarios are supported in Exchange Online. The recommended method for connecting with delegation is using GDAP and App Consent. For more information, see [Use the Exchange Online PowerShell v3 Module with GDAP and App Consent](/powershell/partnercenter/exchange-online-gdap-app). You can also use multi-tenant applications when CSP relationships are not created with the customer. The required steps for using multi-tenant applications are called out within the regular instructions in this article.
56
+
> - Delegated scenarios are supported in Exchange Online. The recommended method for connecting with delegation is using GDAP and App Consent. For more information, see [Use the Exchange Online PowerShell v3 Module with GDAP and App Consent](/powershell/partnercenter/exchange-online-gdap-app). You can also use multitenant applications when CSP relationships aren't created with the customer. The required steps for using multitenant applications are called out within the regular instructions in this article.
56
57
>
57
58
> - Use the _SkipLoadingFormatData_ switch on the **Connect-ExchangeOnline** cmdlet if you get the following error when using the Windows PowerShell SDK to connect: `The term 'Update-ModuleManifest' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.`
58
59
@@ -69,7 +70,7 @@ The following examples show how to use the Exchange Online PowerShell module wit
69
70
>
70
71
> The following connection commands have many of the same options available as described in [Connect to Exchange Online PowerShell](connect-to-exchange-online-powershell.md) and [Connect to Security & Compliance PowerShell](connect-to-scc-powershell.md). For example:
71
72
>
72
-
> - Microsoft 365 GCC High, Microsoft 365 DoD or Microsoft 365 China (operated by 21Vianet) environments require the following additional parameters and values:
73
+
> - Microsoft 365 GCC High, Microsoft 365 DoD, or Microsoft 365 China (operated by 21Vianet) environments require the following extra parameters and values:
> - If a **Connect-IPPSSession** command presents a login prompt, run the command: `$Global:IsWindows = $true` before the **Connect-IPPSSession** command.
86
+
> - If a **Connect-IPPSSession** command presents a sign in prompt, run the command: `$Global:IsWindows = $true` before the **Connect-IPPSSession** command.
86
87
87
88
-**Connect using a certificate thumbprint**:
88
89
@@ -186,17 +187,17 @@ For a detailed visual flow about creating applications in Microsoft Entra ID, se
186
187
- **Name**: Enter something descriptive. For example, ExO PowerShell CBA.
187
188
- **Supported account types**: Verify that **Accounts in this organizational directory only (\<YourOrganizationName\> only - Single tenant)** is selected.
188
189
189
-
> [!TIP]
190
-
> To make the application multi-tenant for **Exchange Online** delegated scenarios, select the value **Accounts in any organizational directory (Any Microsoft Entra directory - Multitenant)**.
190
+
> [!NOTE]
191
+
> To make the application multitenant for **Exchange Online** delegated scenarios, select the value **Accounts in any organizational directory (Any Microsoft Entra directory - Multitenant)**.
191
192
192
193
- **Redirect URI (optional)**: This setting is optional. If you need to use it, configure the following settings:
193
194
- **Platform**: Select **Web**.
194
195
- **URI**: Enter the URI where the access token is sent.
195
196
196
-
> [!TIP]
197
+
> [!NOTE]
197
198
> You can't create credentials for [native applications](/entra/identity/app-proxy/application-proxy-configure-native-client-application), because you can't use native applications for automated applications.
198
199
199
-

200
+

200
201
201
202
When you're finished on the **App registrations** page, select **Register**.
202
203
@@ -207,7 +208,7 @@ For a detailed visual flow about creating applications in Microsoft Entra ID, se
207
208
Choose **one** of the following methods in this section to assign API permissions to the app:
208
209
209
210
- Select and assign the API permissions from the portal.
210
-
- Modify the app manifest to assign API permissions. (Microsoft 365 GCC High and DoD organizations should use this method)
211
+
- Modify the app manifest to assign API permissions. (Microsoft 365 GCC High and DoD organizations should use this method).
211
212
212
213
#### Select and assign the API permissions from the portal
213
214
@@ -337,7 +338,7 @@ Choose **one** of the following methods in this section to assign API permission
337
338
338
339
Create a self-signed x.509 certificate using one of the following methods:
339
340
340
-
- (Recommended) Use the [New-SelfSignedCertificate](/powershell/module/pki/new-selfsignedcertificate), [Export-Certificate](/powershell/module/pki/export-certificate) and [Export-PfxCertificate](/powershell/module/pki/export-pfxcertificate) cmdlets in an elevated (run as administrator) Windows PowerShell session to request a self-signed certificate and export it to `.cer` and `.pfx` (SHA1 by default). For example:
341
+
- (Recommended) Use the [New-SelfSignedCertificate](/powershell/module/pki/new-selfsignedcertificate), [Export-Certificate](/powershell/module/pki/export-certificate), and [Export-PfxCertificate](/powershell/module/pki/export-pfxcertificate) cmdlets in an elevated (run as administrator) Windows PowerShell session to request a self-signed certificate and export it to `.cer` and `.pfx` (SHA1 by default). For example:
341
342
342
343
```powershell
343
344
# Create certificate
@@ -384,16 +385,16 @@ After you register the certificate with your application, you can use the privat
384
385
385
386

386
387
387
-
4. Close the current **Certificates & secrets** page, and then the **App registrations** page to return to the main <https://portal.azure.com/> page. You'll use it in the next step.
388
+
4. Close the current **Certificates & secrets** page, and then the **App registrations** page to return to the main <https://portal.azure.com/> page. You use it in the next step.
388
389
389
-
### Step 4b: Exchange Online delegated scenarios only: Grant admin consent for the multi-tenant app
390
+
### Step 4b: Exchange Online delegated scenarios only: Grant admin consent for the multitenant app
390
391
391
-
If you made the application multi-tenant for **Exchange Online** delegated scenarios in [Step 1](#step-1-register-the-application-in-microsoft-entra-id), you need to grant admin consent to the Exchange.ManageAsApp permission so the application can run cmdlets in Exchange Online **in each tenant organization**. To do this, generate an admin consent URL for each customer tenant. Before anyone uses the multi-tenant application to connect to Exchange Online in the tenant organization, an admin in the customer tenant should open the following URL:
392
+
If you made the application multitenant for **Exchange Online** delegated scenarios in [Step 1](#step-1-register-the-application-in-microsoft-entra-id), you need to grant admin consent to the Exchange.ManageAsApp permission so the application can run cmdlets in Exchange Online **in each tenant organization**. You need to generate an admin consent URL for each customer tenant. Before anyone uses the multitenant application to connect to Exchange Online in the tenant organization, an admin in the customer tenant should open the following URL:
-`<client-id>` is the ID of the multi-tenant application.
397
+
-`<client-id>` is the ID of the multitenant application.
397
398
- The default scope is used to grant application permissions.
398
399
399
400
For more information about the URL syntax, see [Request the permissions from a directory admin](/entra/identity-platform/v2-admin-consent#request-the-permissions-from-a-directory-admin).
@@ -408,13 +409,13 @@ You have two options:
408
409
> [!NOTE]
409
410
> You can also combine both methods to assign permissions. For example, you can use Microsoft Entra roles for the "Exchange Recipient Administrator" role and also assign your custom RBAC role to extend the permissions.
410
411
>
411
-
> For multi-tenant applications in **Exchange Online** delegated scenarios, you need to assign permissions in each customer tenant.
412
+
> For multitenant applications in **Exchange Online** delegated scenarios, you need to assign permissions in each customer tenant.
412
413
413
414
#### Assign Microsoft Entra roles to the application
414
415
415
416
The supported Microsoft Entra roles are described in the following table:
@@ -430,7 +431,7 @@ The supported Microsoft Entra roles are described in the following table:
430
431
- Recipient management.
431
432
- Security and protection features. For example, anti-spam, anti-malware, anti-phishing, and the associated reports.
432
433
433
-
The Security Administrator role does not have the necessary permissions for those same tasks.
434
+
The Security Administrator role doesn't have the necessary permissions for those same tasks.
434
435
435
436
² Microsoft recommends that you use roles with the fewest permissions. Using lower permissioned accounts helps improve security for your organization. Global Administrator is a highly privileged role that should be limited to emergency scenarios when you can't use an existing role.
436
437
@@ -470,7 +471,7 @@ For general instructions about assigning roles in Microsoft Entra ID, see [Assig
470
471
471
472
When you're finished in the **Add assignments** flyout, select **Add**.
472
473
473
-
5. Back on the **Assignments** page, verify that the role has been assigned to the app.
474
+
5. Back on the **Assignments** page, verify that the role is assigned to the app.
474
475
475
476
-**Exchange Online PowerShell**:
476
477
@@ -483,9 +484,9 @@ For general instructions about assigning roles in Microsoft Entra ID, see [Assig
483
484
#### Assign custom role groups to the application using service principals
484
485
485
486
> [!NOTE]
486
-
> You need to connect to Exchange Online PowerShell or Security & Compliance PowerShell _before_ completing steps to create a new service principal. Creating a new service principal without connecting to PowerShell won't work (your Azure App ID and Object ID are needed to create the new service principal).
487
+
> You need to connect to Exchange Online PowerShell or Security & Compliance PowerShell _before_ completing steps to create a new service principal. Creating a new service principal without connecting to PowerShell doesn't work (your Azure App ID and Object ID are needed to create the new service principal).
487
488
>
488
-
> This method is supported only when you connect to Exchange Online PowerShell or Security & Compliance PowerShell in [REST API mode](exchange-online-powershell-v2.md#rest-api-connections-in-the-exo-v3-module). Security & Compliance PowerShell supports REST API mode in v3.2.0 or later.
489
+
> This method is supported only when you connect to Exchange Online PowerShell or Security & Compliance PowerShell in [REST API mode](exchange-online-powershell-v2.md#rest-api-connections-in-the-exo-v3-module). Security & Compliance PowerShell supports REST API mode in v3.2.0 or later.
489
490
490
491
For information about creating custom role groups, see [Create role groups in Exchange Online](/exchange/permissions-exo/role-groups#create-role-groups) and [Create Email & collaboration role groups in the Microsoft Defender portal](/defender-office-365/mdo-portal-permissions#create-email--collaboration-role-groups-in-the-microsoft-defender-portal). The custom role group that you assign to the application can contain any combination of built-in and custom roles.
0 commit comments