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-27Lines changed: 32 additions & 27 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,12 +384,10 @@ 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 **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**.
379
388
380
389

381
390
382
-
When you're finished, select **Add**.
383
-
384
391
The certificate is now shown in the **Certificates** section.
385
392
386
393

@@ -405,19 +412,17 @@ For more information about the URL syntax, see [Request the permissions from a d
405
412
406
413
You have the following options:
407
414
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:
415
+
-[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.
416
+
417
+
-[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
418
- You need to restrict the available commands in your application.
412
419
- You need to use a Write scope to limit which recipients can be modified.
413
420
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.
421
+
- <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
422
416
423
These options are described in the following subsections.
417
424
418
425
> [!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
426
> For multitenant applications in **Exchange Online** delegated scenarios, you need to assign permissions in each customer tenant.
Copy file name to clipboardExpand all lines: exchange/exchange-ps/ExchangePowerShell/Complete-MigrationBatch.md
+30-8Lines changed: 30 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ title: Complete-MigrationBatch
13
13
## SYNOPSIS
14
14
This cmdlet is available in on-premises Exchange and in the cloud-based service. Some parameters and settings might be exclusive to one environment or the other.
15
15
16
-
Use the Complete-MigrationBatch cmdlet to finalize a migration batch for a local move, cross-forest move, or remote move migration that has successfully finished initial synchronization.
16
+
Use the Complete-MigrationBatch cmdlet to finalize a migration batch that has successfully finished initial synchronization.
17
17
18
18
For information about the parameter sets in the Syntax section below, see [Exchange cmdlet syntax](https://learn.microsoft.com/powershell/exchange/exchange-cmdlet-syntax).
After a migration batch for a local or cross-forest move has successfully run and has a status state of Synced, use the Complete-MigrationBatch cmdlet to finalize the migration batch. Finalization is the last phase performed during a local or cross-forest move. When you finalize a migration batch, the cmdlet does the following for each mailbox in the migration batch:
35
+
After a migration batch has successfully run and has a status of Synced or SyncedWithErrors, use the Complete-MigrationBatch cmdlet to finalize the migration batch. When you finalize a migration batch, the cmdlet does the following for each mailbox in the migration batch:
36
36
37
37
- Runs a final incremental synchronization.
38
38
- Configures the user's Microsoft Outlook profile to point to the new target domain.
39
39
- Converts the source mailbox to a mail-enabled user in the source domain.
40
40
41
-
In the cloud-based service, this cmdlet sets the value of CompleteAfter to the current time. It is important to remember that any CompleteAfter setting applied to the individual users within the batch overrides the setting on the batch, so the completion for some users might be delayed until their configured time.
41
+
In the cloud-based service, this cmdlet sets the CompleteAfter value to the current UTC time, which signals the migration service to complete the batch as soon as possible. This is equivalent in intent to running `Set-MigrationBatch -CompleteAfter (Get-Date)`, but without timezone conversion ambiguity.
42
+
43
+
Note the following behavior when using this cmdlet in Exchange Online:
44
+
45
+
- Any CompleteAfter setting applied to individual users within the batch overrides the batch-level setting, so completion for some users might be delayed until their configured time.
46
+
- If you run this cmdlet multiple times within 8 hours after the batch has already been signaled for completion, the migration service may not re-process the request. This behavior is by design to prevent repeated calls from starving the service. If the batch appears stuck after running the cmdlet, check for unapproved skipped items (use `Set-MigrationUser -ApproveSkippedItems`).
42
47
43
48
When the finalization process is complete, you can remove the batch by using the Remove-MigrationBatch cmdlet.
44
49
45
-
If a migration batch has a status of Completed with Errors, you can re-attempt to finalize the failed users. In Exchange Online, use the Start-MigrationBatch cmdlet to retry migration for failed users. In Exchange 2013 or Exchange 2016, use the Complete-MigrationBatch to retry these failed users.
50
+
If a migration batch has a status of Completed with Errors, you can re-attempt to finalize the failed users. In Exchange Online, use the Start-MigrationBatch cmdlet to retry migration for failed users. In Exchange 2013 or later, use the Complete-MigrationBatch to retry these failed users.
46
51
47
52
You need to be assigned permissions before you can run this cmdlet. Although this article lists all parameters for the cmdlet, you might not have access to some parameters if they aren't included in the permissions assigned to you. To find the permissions required to run any cmdlet or parameter in your organization, see [Find the permissions required to run any Exchange cmdlet](https://learn.microsoft.com/powershell/exchange/find-exchange-cmdlet-permissions).
> Applicable: Exchange Server 2016, Exchange Server 2019, Exchange Server SE, Exchange Online
186
190
187
-
The SyncAndComplete switch specifies whether to trigger a synchronization immediately followed by a completion of the migration batch if the synchronization was successful. You don't need to specify a value with this switch.
191
+
The SyncAndComplete switch specifies whether to trigger a final incremental synchronization immediately followed by completion of the migration batch if the synchronization was successful. You don't need to specify a value with this switch.
192
+
193
+
When this switch is used, the batch must have zero failed, corrupted, or stopped items; otherwise, the cmdlet returns an error.
194
+
195
+
**Note:** For Public Folder migration batches, this switch is enabled by default unless the CompletePublicFolderMigrationWithDataLoss switch is also specified.
188
196
189
197
```yaml
190
198
Type: SwitchParameter
@@ -222,13 +230,27 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
222
230
## INPUTS
223
231
224
232
### Input types
225
-
To see the input types that this cmdlet accepts, see [Cmdlet Input and Output Types](https://go.microsoft.com/fwlink/p/?linkId=616387). If the Input Type field for a cmdlet is blank, the cmdlet doesn't accept input data.
233
+
To see the input types that this cmdlet accepts, see [Cmdlet Input and Output Types](https://go.microsoft.com/fwlink/p/?linkId=616387). If the Input Type field for a cmdlet is blank, the cmdlet does not accept input data.
226
234
227
235
## OUTPUTS
228
236
229
237
### Output types
230
-
To see the return types, which are also known as output types, that this cmdlet accepts, see [Cmdlet Input and Output Types](https://go.microsoft.com/fwlink/p/?linkId=616387). If the Output Type field is blank, the cmdlet doesn't return data.
238
+
To see the return types, which are also known as output types, that this cmdlet accepts, see [Cmdlet Input and Output Types](https://go.microsoft.com/fwlink/p/?linkId=616387). If the Output Type field is blank, the cmdlet does not return data.
231
239
232
240
## NOTES
233
241
242
+
In Exchange Online, this cmdlet is supported for the following migration types:
243
+
244
+
- Exchange Local Move
245
+
- Exchange Remote Move
246
+
- Gmail
247
+
- Google Resource
248
+
- Local Relocation
249
+
- Folder Move
250
+
- PST Import
251
+
- Public Folder
252
+
- Public Folder to Unified Group
253
+
254
+
In Exchange Online, this cmdlet isn't supported for IMAP, staged Exchange Outlook Anywhere (cutover), or Bulk Provisioning migrations, which don't have a finalization step.
**Note**: If your organization has more han 1000 sensitivity labels, the timeout settings set for the Powershell session may cause performance issues. Use the SkipValidations parameter to retrieve labels more efficiently.
33
+
32
34
To use this cmdlet in Security & Compliance PowerShell, you need to be assigned permissions. For more information, see [Permissions in the Microsoft Purview compliance portal](https://learn.microsoft.com/purview/microsoft-365-compliance-center-permissions).
The SkipValidations switch specifies whether to skip the retrieval of encryption properties configured in sensitivity labels. You don't need to specify a value with this switch.
119
+
120
+
Organizations with more than 1000 labels can use this switch to reduce the time required to fetch the labels, which helps prevent timeout issues with Get-Label cmdlet.
121
+
122
+
**Note**: Using this switch doesn't skip validations when you retrieve labels. It only skips the the retrieval of encryption template properties if they're configured for a label. You can get those properties individually by using the Identity parameter in the Get-Label command.
123
+
124
+
This switch doesn't affect label application or distribution. The limitation exists only when fetching labels for CRUD operations.
0 commit comments