Skip to content

Commit 3ea2672

Browse files
committed
Update app-only-auth-powershell-v2.md
Replaced GetAzureADServicePrincipal with GetMgServicePrincipal and required follow-up udpates, and general, unrelated text clean-up.
1 parent e587544 commit 3ea2672

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: App-only authentication in Exchange Online PowerShell and Security & Comp
33
ms.author: chrisda
44
author: chrisda
55
manager: dansimp
6-
ms.date: 8/22/2023
6+
ms.date: 8/25/2023
77
ms.audience: Admin
88
audience: Admin
99
ms.topic: article
@@ -134,18 +134,18 @@ For a detailed visual flow about creating applications in Azure AD, see <https:/
134134
135135
2. [Assign API permissions to the application](#step-2-assign-api-permissions-to-the-application).
136136
137-
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`.
137+
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**.
138138
139139
3. [Generate a self-signed certificate](#step-3-generate-a-self-signed-certificate)
140140
141141
- For app-only authentication in Azure AD, 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.
142142
143143
- Create and configure a self-signed X.509 certificate, which is used to authenticate your Application against Azure AD, while requesting the app-only access token.
144144
145-
- This procedure is similar to generating a password for user accounts. The certificate can be self-signed as well. See the [Appendix](#step-3-generate-a-self-signed-certificate) section later in this article for instructions for generating certificates in PowerShell.
145+
- 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.
146146
147147
> [!NOTE]
148-
> Cryptography: Next Generation (CNG) certificates are not supported for app-only authentication with Exchange. CNG certificates are created by default in modern Windows versions. You must use a certificate from a CSP key provider. The [Appendix](#step-3-generate-a-self-signed-certificate) section covers two supported methods to create a CSP certificate.
148+
> 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.
149149
150150
4. [Attach the certificate to the Azure AD application](#step-4-attach-the-certificate-to-the-azure-ad-application)
151151
@@ -179,7 +179,9 @@ For a detailed visual flow about creating applications in Azure AD, see <https:/
179179
> [!NOTE]
180180
> To make the application multi-tenant for **Exchange Online** delegated scenarios, select the value **Accounts in any organizational directory (Any Azure AD directory - Multitenant)**.
181181
182-
- **Redirect URI (optional)**: This setting is optional. In the first box, verify that **Web** is selected. In the second box, enter the URI where the access token is sent.
182+
- **Redirect URI (optional)**: This setting is optional. If you need to use it, configure the following settings:
183+
- **Platform**: Select **Web**.
184+
- **URI**: Enter the URI where the access token is sent.
183185
184186
> [!NOTE]
185187
> You can't create credentials for [native applications](/azure/active-directory/manage-apps/application-proxy-configure-native-client-application), because you can't use native applications for automated applications.
@@ -309,7 +311,7 @@ Choose **one** of the following methods in this section to assign API permission
309311
310312
- **Status**: The current incorrect value is **Not granted for \<Organization\>** for the **Office 365 Exchange Online** \> **Exchange.ManageAsApp** entry.
311313
312-
Change this value by selecting **Grant admin consent for \<Organization\>**, reading the confirmation dialog that opens, and then selecting **Yes**.
314+
Change the **Status** value by selecting **Grant admin consent for \<Organization\>**, reading the confirmation dialog that opens, and then selecting **Yes**.
313315
314316
![Admin consent required but not granted for Exchange.ManageAsApp permissions.](media/exo-app-only-auth-original-permissions.png)
315317
@@ -480,36 +482,40 @@ For information about creating custom role groups, see [Create role groups in Ex
480482

481483
To assign custom role groups to the application using service principals, do the following steps:
482484

483-
1. In [Azure Active Directory PowerShell for Graph](/powershell/azure/active-directory/install-adv2), run the following command to store the details of the Azure application that you registered in [Step 1](#step-1-register-the-application-in-azure-ad) in a variable:
485+
1. In [Microsoft Graph PowerShell](/powershell/microsoftgraph/installation), run the following commands to store the details of the Azure AD application that you registered in [Step 1](#step-1-register-the-application-in-azure-ad) in a variable:
484486

485487
```powershell
486-
$<VariableName1> = Get-AzureADServicePrincipal -SearchString "<AppName>"
488+
Connect-MgGraph -Scopes AppRoleAssignment.ReadWrite.All,Application.Read.All
489+
490+
$<VariableName1> = Get-MgServicePrincipal -Filter "DisplayName eq '<AppName>'"
487491
```
488492

489493
For example:
490494

491495
```powershell
492-
$AADApp = Get-AzureADServicePrincipal -SearchString "ExO PowerShell CBA"
496+
Connect-MgGraph -Scopes AppRoleAssignment.ReadWrite.All,Application.Read.All
497+
498+
$AzureADApp = Get-MgServicePrincipal -Filter "DisplayName eq 'ExO PowerShell CBA'"
493499
```
494500

495-
For detailed syntax and parameter information, see [Get-AzureADServicePrincipal](/powershell/module/azuread/get-azureadserviceprincipal).
501+
For detailed syntax and parameter information, see [Get-MgServicePrincipal](/powershell/module/microsoft.graph.applications/get-mgserviceprincipal).
496502

497503
2. In the same PowerShell window, connect to [Exchange Online PowerShell](connect-to-exchange-online-powershell.md) or [Security & Compliance PowerShell](connect-to-scc-powershell.md) and run the following commands to:
498-
- Create a service principal object for the Azure application.
499-
- Store the details of the service principal in a variable.
504+
- Create a service principal object for the Azure AD application.
505+
- Store the details of the service principal in a variable to use in the next step.
500506

501507
```powershell
502-
New-ServicePrincipal -AppId $<VariableName1>.AppId -ObjectId $<VariableName1>.ObjectId -DisplayName "<Descriptive Name>"
508+
New-ServicePrincipal -AppId $<VariableName1>.AppId -ObjectId $<VariableName1>.Id -DisplayName "<Descriptive Name>"
503509
504510
$<VariableName2> = Get-ServicePrincipal -Identity "<Descriptive Name>"
505511
```
506512

507513
For example:
508514

509515
```powershell
510-
New-ServicePrincipal -AppId $AADApp.AppId -ObjectId $AADApp.ObjectId -DisplayName "SP for Azure App ExO PowerShell CBA"
516+
New-ServicePrincipal -AppId $AzureADApp.AppId -ObjectId $AzureADApp.Id -DisplayName "SP for Azure AD App ExO PowerShell CBA"
511517
512-
$SP = Get-ServicePrincipal -Identity "SP for Azure App ExO PowerShell CBA"
518+
$SP = Get-ServicePrincipal -Identity "SP for Azure AD App ExO PowerShell CBA"
513519
```
514520

515521
For detailed syntax and parameter information, see [New-ServicePrincipal](/powershell/module/exchange/new-serviceprincipal).

0 commit comments

Comments
 (0)