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
+48-39Lines changed: 48 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,22 @@
1
1
---
2
2
title: App-only authentication in Exchange Online PowerShell and Security & Compliance PowerShell
3
-
ms.author: chrisda
4
-
author: chrisda
5
-
manager: orspodek
6
-
ms.date: 12/05/2025
3
+
ms.date: 03/11/2026
7
4
ms.audience: Admin
8
-
audience: Admin
9
5
ms.topic: article
10
6
ms.service: exchange-online
11
7
ms.reviewer:
12
8
ms.localizationpriority: high
13
9
ms.collection: Strat_EX_Admin
14
10
ms.custom:
15
11
ms.assetid:
16
-
search.appverid: MET150
17
12
description: "Learn how to configure app-only authentication (also known as certificate based authentication or CBA) using the Exchange Online PowerShell V3 module in scripts and other long-running tasks."
18
13
---
19
14
20
15
# App-only authentication for unattended scripts in Exchange Online PowerShell and Security & Compliance PowerShell
21
16
22
17
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
18
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.
19
+
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 certificates.
25
20
26
21
> [!NOTE]
27
22
>
@@ -154,22 +149,20 @@ For a detailed visual flow about creating applications in Microsoft Entra ID, se
154
149
155
150
An application object has the **Delegated** API permission **Microsoft Graph** \> **User.Read** by default. For the application object to access resources in Exchange, it needs the **Application** API permission **Office 365 Exchange Online** \> **Exchange.ManageAsApp**.
156
151
157
-
3. [Generate a self-signed certificate](#step-3-generate-a-self-signed-certificate)
152
+
3. [Generate a certificate](#step-3-generate-a-certificate)
158
153
159
154
- For app-only authentication in Microsoft Entra ID, you typically use a certificate to request access. Anyone who has the certificate and its private key can use the app with the permissions granted to the app.
160
155
161
-
- Create and configure a self-signed X.509 certificate, which is used to authenticate your Application against Microsoft Entra ID, while requesting the app-only access token.
156
+
- Create and configure an X.509 certificate, which is used to authenticate your Application against Microsoft Entra ID, while requesting the app-only access token. The certificate can be self-signed.
162
157
163
-
- This procedure is similar to generating a password for user accounts. The certificate can be self-signed as well. See [this section](#step-3-generate-a-self-signed-certificate) later in this article for instructions to generate certificates in PowerShell.
158
+
- This procedure is similar to generating a password for user accounts. See [this section](#step-3-generate-a-certificate) later in this article for instructions to generate certificates in PowerShell.
164
159
165
160
> [!NOTE]
166
-
> Cryptography: Next Generation (CNG) certificates aren't supported for app-only authentication with Exchange. CNG certificates are created by default in modern versions of Windows. You must use a certificate from a CSP key provider. [This section](#step-3-generate-a-self-signed-certificate) section covers two supported methods to create a CSP certificate.
161
+
> Cryptography: Next Generation (CNG) certificates aren't supported for app-only authentication with Exchange. CNG certificates are created by default in modern versions of Windows. You must use a certificate from a CSP key provider. [This section](#step-3-generate-a-certificate) section covers two supported methods to create a CSP certificate.
167
162
168
163
4. [Attach the certificate to the Microsoft Entra application](#step-4-attach-the-certificate-to-the-microsoft-entra-application)
169
164
170
-
5. [Assign Microsoft Entra roles to the application](#step-5-assign-microsoft-entra-roles-to-the-application)
171
-
172
-
The application needs to have the appropriate RBAC roles assigned. Because the apps are provisioned in Microsoft Entra ID, you can use any of the supported built-in roles.
165
+
5. [Assign roles permissions to the application](#step-5-assign-role-permissions-to-the-application)
173
166
174
167
### Step 1: Register the application in Microsoft Entra ID
175
168
@@ -339,27 +332,36 @@ Choose **one** of the following methods in this section to assign API permission
339
332
340
333
6. Close the current **API permissions** page (not the browser tab) to return to the **App registrations** page. You use the **App registrations** page in an upcoming step.
Create a self-signed x.509 certificate using one of the following methods:
337
+
### Step 3: Generate a certificate
345
338
346
-
- (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:
339
+
> [!NOTE]
340
+
> Cryptography: Next Generation (CNG) certificates aren't supported for app-only authentication as described in this article. CNG certificates are created by default in modern Windows versions. You need to use a certificate from a CSP key provider.
341
+
>
342
+
> You can use a self-signed certificate, a certificate issued by an internal public key infrastructure or PKI (for example, Active Directory Certificate Services or AD CS), or a certificate issued by a trusted commercial certificate authority (CA).
343
+
>
344
+
> The only requirements for the X.509 certificate are an exportable and available private key (.pfx) and public certificate (.cer).
- (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 PowerShell session (a PowerShell window you opened after selecting **Run as administrator**) to request a self-signed certificate and export the certificate's private and public keys to files (SHA1 by default). For example:
# Export the X.509 public certificate to a .cer file
358
+
$mycert | Export-Certificate -FilePath mycert.cer
359
+
```
358
360
359
361
- Use the [Create-SelfSignedCertificate script](https://github.com/SharePoint/PnP-Partner-Pack/blob/master/scripts/Create-SelfSignedCertificate.ps1) script to generate SHA1 certificates.
### Step 4: Attach the certificate to the Microsoft Entra application
@@ -380,12 +382,10 @@ After you register the certificate with your application, you can use the privat
380
382
381
383

382
384
383
-
In the dialog that opens, browse to the self-signed certificate (`.cer` file) that you created in [Step 3](#step-3-generate-a-self-signed-certificate).
385
+
In the **Upload certificate** flyout that opens, browse to the public certificate (`.cer` file) you exported in [Step 3](#step-3-generate-a-certificate), and then select **Add**.
384
386
385
387

386
388
387
-
When you're finished, select **Add**.
388
-
389
389
The certificate is now shown in the **Certificates** section.
390
390
391
391

@@ -404,19 +404,28 @@ If you made the application multitenant for **Exchange Online** delegated scenar
404
404
405
405
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).
406
406
407
-
### Step 5: Assign Microsoft Entra roles to the application
### Step 5: Assign role permissions to the application
410
+
411
+
You have the following options:
412
+
413
+
-[Option 1: Assign Microsoft Entra roles to the application](#option-1-assign-microsoft-entra-roles-to-the-application): Use built-in Microsoft Entra roles to grant all permissions of the role. You can't customize or scope these roles.
414
+
415
+
-[Option 2: Assign custom role groups to the application using service principals](#option-2-assign-custom-role-groups-to-the-application-using-service-principals): We recommend this option in the following scenarios:
416
+
- You need to restrict the available commands in your application.
417
+
- You need to use a Write scope to limit which recipients can be modified.
408
418
409
-
You have two options:
419
+
- <u>Option 3: Combine Microsoft Entra roles with custom role groups</u>: RBAC combines permissions from all sources. We recommend this method to extend the capabilities of a built-in Microsoft Entra role. For example, you can extend the capabilities of the **Exchange Recipient Administrator** role by granting extra permissions from a custom role.
410
420
411
-
-**Assign Microsoft Entra roles to the application**
412
-
-**Assign custom role groups to the application using service principals**: 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.
421
+
These options are described in the following subsections.
413
422
414
423
> [!NOTE]
415
-
> 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.
416
-
>
417
424
> For multitenant applications in **Exchange Online** delegated scenarios, you need to assign permissions in each customer tenant.
418
425
419
-
#### Assign Microsoft Entra roles to the application
#### Option 1: Assign Microsoft Entra roles to the application
420
429
421
430
The supported Microsoft Entra roles are described in the following table:
422
431
@@ -487,12 +496,12 @@ For general instructions about assigning roles in Microsoft Entra ID, see [Assig
487
496
488
497

489
498
490
-
#### Assign custom role groups to the application using service principals
#### Option 2: Assign custom role groups to the application using service principals
491
502
492
503
> [!NOTE]
493
504
> 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).
494
-
>
495
-
> 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.
496
505
497
506
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.
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/cmdlet-property-sets.md
-6Lines changed: 0 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,13 @@
1
1
---
2
2
title: Property sets in Exchange Online PowerShell module cmdlets
3
-
ms.author: chrisda
4
-
author: chrisda
5
-
manager: orspodek
6
3
ms.date: 9/1/2023
7
4
ms.audience: Admin
8
-
audience: Admin
9
5
ms.topic: article
10
-
ms.service: exchange-powershell
11
6
ms.reviewer:
12
7
ms.localizationpriority: high
13
8
ms.collection: Strat_EX_Admin
14
9
ms.custom:
15
10
ms.assetid:
16
-
search.appverid: MET150
17
11
description: "Admins can lear about the property sets that are available in the nine exclusive Get-EXO cmdlets in the Exchange Online PowerShell V2 module and V3 module."
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/connect-to-exchange-online-powershell.md
-5Lines changed: 0 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,13 @@
1
1
---
2
2
title: Connect to Exchange Online PowerShell
3
-
author: chrisda
4
-
manager: orspodek
5
3
ms.date: 07/11/2025
6
4
ms.audience: Admin
7
-
audience: Admin
8
5
ms.topic: article
9
-
ms.service: exchange-powershell
10
6
ms.reviewer:
11
7
ms.localizationpriority: high
12
8
ms.collection: Strat_EX_Admin
13
9
ms.custom:
14
10
ms.assetid:
15
-
search.appverid: MET150
16
11
description: "Learn how to use the Exchange Online PowerShell V3 module to connect to Exchange Online PowerShell with modern authentication and/or multifactor authentication (MFA)."
Copy file name to clipboardExpand all lines: exchange/docs-conceptual/connect-to-scc-powershell.md
-5Lines changed: 0 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,13 @@
1
1
---
2
2
title: Connect to Security & Compliance PowerShell
3
-
author: chrisda
4
-
manager: orspodek
5
3
ms.date: 12/05/2025
6
4
ms.audience: Admin
7
-
audience: Admin
8
5
ms.topic: article
9
-
ms.service: exchange-powershell
10
6
ms.reviewer:
11
7
ms.localizationpriority: high
12
8
ms.collection: Strat_EX_Admin
13
9
ms.custom:
14
10
ms.assetid:
15
-
search.appverid: MET150
16
11
description: "Learn how to use the Exchange Online PowerShell V3 module to connect to Security & Compliance PowerShell with modern authentication and/or multifactor authentication (MFA)."
0 commit comments