Skip to content

Commit cfffa99

Browse files
authored
Revise app-only auth documentation for clarity
Updated the documentation for app-only authentication in Exchange Online PowerShell to improve clarity and accuracy regarding version requirements and other details.
1 parent 899b483 commit cfffa99

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

exchange/docs-conceptual/app-only-auth-powershell-v2.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,25 @@ description: "Learn how to configure app-only authentication (also known as cert
1919

2020
# App-only authentication for unattended scripts in Exchange Online PowerShell and Security & Compliance PowerShell
2121

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.
2323

2424
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.
2525

2626
> [!NOTE]
27+
>
2728
> - 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).
2829
>
2930
> - 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.
3233
>
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).
3435
>
3536
> - CBA or app-only authentication is available in Office 365 operated by 21Vianet in China.
3637
>
3738
> - 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).
3839
>
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`.
4041
>
4142
> - In Exchange Online PowerShell, you can't use the procedures in this article with the following Microsoft 365 Group cmdlets:
4243
> - [New-UnifiedGroup](/powershell/module/exchangepowershell/new-unifiedgroup)
@@ -47,12 +48,12 @@ Certificate based authentication (CBA) or app-only authentication as described i
4748
> 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).
4849
>
4950
> - In Security & Compliance PowerShell, you can't use the procedures in this article with the following Microsoft Purview cmdlets:
50-
> - [Get-ComplianceSearchAction](/powershell/module/exchangepowershell/get-compliancesearchaction)
51-
> - [New-ComplianceSearch](/powershell/module/exchangepowershell/new-compliancesearch)
52-
> - [Start-ComplianceSearch](/powershell/module/exchangepowershell/start-compliancesearch)
53-
> - [New-ComplianceSearchAction](/powershell/module/exchangepowershell/new-compliancesearchaction?view=exchange-ps)
51+
> - [Get-ComplianceSearchAction](/powershell/module/exchangepowershell/get-compliancesearchaction)
52+
> - [New-ComplianceSearch](/powershell/module/exchangepowershell/new-compliancesearch)
53+
> - [Start-ComplianceSearch](/powershell/module/exchangepowershell/start-compliancesearch)
54+
> - [New-ComplianceSearchAction](/powershell/module/exchangepowershell/new-compliancesearchaction?view=exchange-ps)
5455
>
55-
> - 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.
5657
>
5758
> - 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.`
5859
@@ -69,7 +70,7 @@ The following examples show how to use the Exchange Online PowerShell module wit
6970
>
7071
> 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:
7172
>
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:
7374
> - **Microsoft 365 GCC High**
7475
> - `Connect-ExchangeOnline -ExchangeEnvironmentName O365USGovGCCHigh`
7576
> - `Connect-IPPSSession -ConnectionUri https://ps.compliance.protection.office365.us/powershell-liveid/ -AzureADAuthorizationEndpointUri https://login.microsoftonline.us`
@@ -82,7 +83,7 @@ The following examples show how to use the Exchange Online PowerShell module wit
8283
> - `Connect-ExchangeOnline -ExchangeEnvironmentName O365China`
8384
> - `Connect-IPPSSession -ConnectionUri https://ps.compliance.protection.partner.outlook.cn/powershell-liveid -AzureADAuthorizationEndpointUri https://login.chinacloudapi.cn/common`
8485
>
85-
> - 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.
8687
8788
- **Connect using a certificate thumbprint**:
8889

@@ -186,17 +187,17 @@ For a detailed visual flow about creating applications in Microsoft Entra ID, se
186187
- **Name**: Enter something descriptive. For example, ExO PowerShell CBA.
187188
- **Supported account types**: Verify that **Accounts in this organizational directory only (\<YourOrganizationName\> only - Single tenant)** is selected.
188189
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)**.
191192
192193
- **Redirect URI (optional)**: This setting is optional. If you need to use it, configure the following settings:
193194
- **Platform**: Select **Web**.
194195
- **URI**: Enter the URI where the access token is sent.
195196
196-
> [!TIP]
197+
> [!NOTE]
197198
> 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.
198199
199-
![Register an application.](media/exo-app-only-auth-register-app.png)
200+
![Register an application.](media/exo-app-only-auth-register-app.png)
200201
201202
When you're finished on the **App registrations** page, select **Register**.
202203
@@ -207,7 +208,7 @@ For a detailed visual flow about creating applications in Microsoft Entra ID, se
207208
Choose **one** of the following methods in this section to assign API permissions to the app:
208209
209210
- 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).
211212
212213
#### Select and assign the API permissions from the portal
213214
@@ -337,7 +338,7 @@ Choose **one** of the following methods in this section to assign API permission
337338
338339
Create a self-signed x.509 certificate using one of the following methods:
339340
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:
341342
342343
```powershell
343344
# Create certificate
@@ -384,16 +385,16 @@ After you register the certificate with your application, you can use the privat
384385

385386
![Application page showing that the certificate was added.](media/exo-app-only-auth-certificate-successfully-added.png)
386387

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.
388389

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
390391

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:
392393

393394
`https://login.microsoftonline.com/<tenant-id>/adminconsent?client_id=<client-id>&scope=https://outlook.office365.com/.default`
394395

395396
- `<tenant-id>` is the customer's tenant ID.
396-
- `<client-id>` is the ID of the multi-tenant application.
397+
- `<client-id>` is the ID of the multitenant application.
397398
- The default scope is used to grant application permissions.
398399

399400
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:
408409
> [!NOTE]
409410
> 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.
410411
>
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.
412413
413414
#### Assign Microsoft Entra roles to the application
414415

415416
The supported Microsoft Entra roles are described in the following table:
416417

417-
|Role|Exchange Online<br>PowerShell|Security & Compliance<br>PowerShell|
418+
|Role|Exchange Online<br/>PowerShell|Security & Compliance<br/>PowerShell|
418419
|---|:---:|:---:|
419420
|[Compliance Administrator](/entra/identity/role-based-access-control/permissions-reference#compliance-administrator)|||
420421
|[Exchange Administrator](/entra/identity/role-based-access-control/permissions-reference#exchange-administrator)¹|||
@@ -430,7 +431,7 @@ The supported Microsoft Entra roles are described in the following table:
430431
- Recipient management.
431432
- Security and protection features. For example, anti-spam, anti-malware, anti-phishing, and the associated reports.
432433

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.
434435

435436
² 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.
436437

@@ -470,7 +471,7 @@ For general instructions about assigning roles in Microsoft Entra ID, see [Assig
470471

471472
When you're finished in the **Add assignments** flyout, select **Add**.
472473

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.
474475

475476
- **Exchange Online PowerShell**:
476477

@@ -483,9 +484,9 @@ For general instructions about assigning roles in Microsoft Entra ID, see [Assig
483484
#### Assign custom role groups to the application using service principals
484485

485486
> [!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).
487488
>
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.
489490
490491
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.
491492

0 commit comments

Comments
 (0)