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
+32-25Lines changed: 32 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: App-only authentication in Exchange Online PowerShell and Security & Compliance PowerShell
3
-
ms.date: 02/27/2026
3
+
ms.date: 03/11/2026
4
4
ms.audience: Admin
5
5
audience: Admin
6
6
ms.topic: article
@@ -18,7 +18,7 @@ description: "Learn how to configure app-only authentication (also known as cert
18
18
19
19
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.
20
20
21
-
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.
21
+
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.
22
22
23
23
> [!NOTE]
24
24
>
@@ -151,16 +151,16 @@ For a detailed visual flow about creating applications in Microsoft Entra ID, se
151
151
152
152
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**.
153
153
154
-
3. [Generate a self-signed certificate](#step-3-generate-a-self-signed-certificate)
154
+
3. [Generate a certificate](#step-3-generate-a-certificate)
155
155
156
156
- 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.
157
157
158
-
- 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.
158
+
- 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.
159
159
160
-
- 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.
160
+
- 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.
161
161
162
162
> [!NOTE]
163
-
> 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.
163
+
> 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.
164
164
165
165
4. [Attach the certificate to the Microsoft Entra application](#step-4-attach-the-certificate-to-the-microsoft-entra-application)
166
166
@@ -334,27 +334,36 @@ Choose **one** of the following methods in this section to assign API permission
334
334
335
335
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:
339
+
### Step 3: Generate a certificate
340
340
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
+
> [!NOTE]
342
+
> 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.
343
+
>
344
+
> 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).
345
+
>
346
+
> 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
360
+
$mycert | Export-Certificate -FilePath mycert.cer
361
+
```
353
362
354
363
- 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
@@ -375,7 +384,7 @@ After you register the certificate with your application, you can use the privat
375
384
376
385

377
386
378
-
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).
387
+
In the dialog that opens, browse to the public certificate (`.cer` file) you exported in [Step 3](#step-3-generate-a-certificate).
379
388
380
389

381
390
@@ -405,19 +414,17 @@ For more information about the URL syntax, see [Request the permissions from a d
405
414
406
415
You have the following options:
407
416
408
-
-**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.
409
-
410
-
-**Option 2: Assign custom role groups to the application using service principals**: We recommend this option in the following scenarios:
417
+
-[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.
418
+
419
+
-[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:
411
420
- You need to restrict the available commands in your application.
412
421
- You need to use a Write scope to limit which recipients can be modified.
413
422
414
-
-**Option 3: Combine Microsoft Entra roles with custom role groups**: We recommend this method to extend a built-in Microsoft Entra role (for example, the **Exchange Recipient Administrator** role) by granting extra permissions from a custom role.
423
+
- <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.
415
424
416
425
These options are described in the following subsections.
417
426
418
427
> [!NOTE]
419
-
> RBAC combines permissions from all sources. For example, you can use the **Exchange Recipient Administrator** role in Microsoft Entra and also assign your custom RBAC role to extend the permissions.
420
-
>
421
428
> For multitenant applications in **Exchange Online** delegated scenarios, you need to assign permissions in each customer tenant.
0 commit comments