--- title: "How to configure Microsoft 365: Dex MSP" slug: "dex-msp-add-tenant-microsoft-365" updated: 2026-11-30T13:03:25Z published: 2026-11-30T13:03:25Z canonical: "documentation.sysaid.com/dex-msp-add-tenant-microsoft-365" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt > Use this file to discover all available pages before exploring further. # How to configure Microsoft 365: Dex MSP MSP DOCUMENTATION ## How to configure Microsoft 365 Create a Microsoft 365 app registration that Dex can use to manage a customer tenant. About 3 minutes with the automated PowerShell script, or 5–10 minutes manually, requires Global Administrator on the customer's tenant. ## Overview This guide walks you through creating a Microsoft 365 app registration that Dex can use to manage a customer tenant. At the end you will have three values to paste into the Add tenant dialog: - Directory (tenant) ID - Application (client) ID - Client secret value The automated script takes about 3 minutes; the manual route 5–10 minutes. Either way, it must be performed by someone with Global Administrator (or Privileged Role Administrator + Cloud Application Administrator) on the customer's Microsoft 365 tenant. APP-ONLY INTEGRATION Dex uses an application (app-only) integration, not a delegated user login. This means Dex can act on the tenant even when no user is signed in, which is required for autonomous remediation and scheduled discovery. ### CHOOSE HOW YOU WANT TO SET IT UP **Automated, PowerShell script** (Recommended · ~3 min) One script creates the app registration, secret, and all permissions, grants admin consent, and prints the three values. **Manual, Entra portal** (~10 min) Click through the Entra admin center yourself: register the app, create a secret, and grant each permission. Both paths end at the same place: three values to paste into the Dex Add tenant dialog. The guide below shows only the path you pick. --- ## Variant A: Automated, PowerShell script ## Run the setup script Instead of clicking through the Entra portal, run one script that creates the app registration, the client secret, all required Microsoft Graph permissions, and grants admin consent, then prints the three values you need for the Dex Add tenant dialog. Takes about 3 minutes per tenant and requires a Global Administrator account on the customer's tenant. Download: https://download.dex365.ai/windows/Setup-DexTenant.ps1 ### Option A: Azure Cloud Shell (nothing to install) Cloud Shell runs in the browser with the Microsoft Graph modules already available, so this works the same on any computer. 1. Open a private/incognito window (so you don't mix up tenants) and go to https://shell.azure.com. 2. Sign in with a Global Administrator account of the customer's tenant. If prompted, choose PowerShell (not Bash) and No storage account required if offered. 3. Paste these two lines and press Enter: ``` Invoke-WebRequest -Uri "https://download.dex365.ai/windows/Setup-DexTenant.ps1" -OutFile Setup-DexTenant.ps1 ./Setup-DexTenant.ps1 ``` 1. When prompted, sign in with the same Global Admin account and accept the requested permissions (Application.ReadWrite.All, AppRoleAssignment.ReadWrite.All). This consent is for running the script, not for Dex itself. 2. When the script finishes, copy the three printed values (Tenant ID, Client ID, and Client Secret), and continue to Add the tenant in Dex below. **Copy the client secret now** It is shown only once and cannot be retrieved later. If you lose it, re-run the script or create a new secret in Entra. ### Option B: Local PowerShell (Windows, macOS, or Linux) PowerShell 7+ recommended (Windows PowerShell 5.1 also works). The script auto-installs the Microsoft.Graph.Authentication and Microsoft.Graph.Applications modules to your user profile if missing. No admin rights are needed on the computer, only on the tenant. ``` Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass Invoke-WebRequest -Uri "https://download.dex365.ai/windows/Setup-DexTenant.ps1" -OutFile Setup-DexTenant.ps1 ./Setup-DexTenant.ps1 ``` Sign in with a Global Administrator of the customer's tenant when the browser prompt appears, then copy the three printed values into the Dex Add tenant dialog. Managing multiple tenants from one machine? Force the right tenant explicitly: ``` ./Setup-DexTenant.ps1 -TenantId "customer-tenant-id-or-domain.onmicrosoft.com" ``` ### Optional parameters | PARAMETER | DEFAULT | DESCRIPTION | | --- | --- | --- | | -AppName | Dex | Display name of the app registration in Entra. | | -SecretMonths | 24 | Client secret lifetime in months. | | -TenantId | (interactive) | Force sign-in to a specific tenant, useful for MSPs with many tenants. | ### What the script does 1. Signs in to Microsoft Graph as you (Global Admin), requesting only Application.ReadWrite.All and AppRoleAssignment.ReadWrite.All for the session. 2. Creates a single-tenant app registration named Dex. 3. Creates a client secret (24 months by default). 4. Adds all 27 Microsoft Graph application permissions required by Dex (full list below). 5. Creates the service principal (Enterprise Application). 6. Grants admin consent for every permission. 7. Prints the Tenant ID, Client ID, and Client Secret and disconnects. The script makes no other changes to the tenant and stores nothing. Once it finishes, continue to Add the tenant in Dex below. ## Add the tenant in Dex 1. In the Dex MSP dashboard, click Add tenant. 2. Enter an Organization name (this is the label that will show in your MSP dashboard, it does not need to match the M365 tenant name). 3. Select Microsoft 365. 4. Paste the three values you collected: - Tenant ID → printed by the script - Client ID → printed by the script - Client Secret → printed by the script (shown only once) 5. Click Add Tenant. Dex will: 1. Acquire an app-only token to verify the credentials are valid. 2. Call /organization on Microsoft Graph to confirm the tenant matches. 3. Look up the service principal and list its granted app roles. 4. Compare granted roles against the required list and report any missing ones. If everything succeeds, the tenant appears in your MSP dashboard and Dex automatically starts a discovery scan. ## Permissions the script granted For reference: these are the 27 Microsoft Graph application permissions Setup-DexTenant.ps1 added and consented to, and why Dex needs each one. **Core identity & directory** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | User.ReadWrite.All | Create, update, disable, and delete users; reset passwords; manage licenses. | | Directory.ReadWrite.All | Read and write directory objects (users, groups, devices) for org-wide operations. | | Group.ReadWrite.All | Create and manage Microsoft 365 groups, security groups, and distribution lists. | | GroupMember.ReadWrite.All | Add and remove members from groups. | | UserAuthenticationMethod.ReadWrite.All | Manage MFA methods, register/reset authentication methods. | **Audit & security** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | AuditLog.Read.All | Read sign-in and audit logs for incident investigation. | | Application.Read.All | Read app registrations and service principals during discovery. | | RoleManagement.Read.Directory | Read directory role assignments to evaluate privilege. | | BitlockerKey.Read.All | Retrieve BitLocker recovery keys for device recovery workflows. | **Intune / device management** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | DeviceManagementApps.ReadWrite.All | Manage Intune app deployments. | | DeviceManagementConfiguration.Read.All | Read Intune configuration and compliance policies. | | DeviceManagementManagedDevices.PrivilegedOperations.All | Wipe, retire, remote lock, and reset managed devices. | | DeviceManagementManagedDevices.ReadWrite.All | Read and update managed device records. | **Exchange / mail** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | Mail.Send | Send notification and remediation emails from user mailboxes. | | Mail.ReadWrite | Read and modify mailbox contents during investigation and cleanup. | | Calendars.ReadWrite | Manage calendar events during onboarding/offboarding. | | MailboxSettings.ReadWrite | Configure mailbox settings (forwarding, OOO, delegates). | **SharePoint / files** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | Sites.Read.All | Read SharePoint site metadata for discovery. | | Sites.ReadWrite.All | Manage SharePoint sites and lists. | | Sites.FullControl.All | Required for site provisioning and permission management. | | Files.Read.All | Read OneDrive / SharePoint files for investigation. | | Files.ReadWrite.All | Manage files during offboarding and content cleanup. | **Reports & organization** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | Organization.Read.All | Read tenant info (display name, verified domains, licenses). | | Reports.Read.All | Pull usage and activity reports for posture analysis. | | ReportSettings.ReadWrite.All | Enable de-anonymized reports so user-level usage data is available. | **Teams** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | TeamsAppInstallation.ReadWriteForUser.All | Install the Dex Teams app for end users. | | AppCatalog.ReadWrite.All | Upload and update the Dex Teams app in the tenant app catalog. | ## Troubleshooting (Automated variant) **INVALID_CREDENTIALS** - Double-check you pasted the Tenant ID (not the tenant domain like contoso.onmicrosoft.com). - Confirm the Client Secret is the Value, not the Secret ID. - Confirm the secret has not expired. Go to Certificates & secrets in Entra and check the Expires column. **MISSING_PERMISSIONS** The error response includes the exact list of missing permissions. Go back to API permissions in the app registration, add the missing ones, and click Grant admin consent again. Then retry Add Tenant. **SERVICE_PRINCIPAL_NOT_FOUND** The app registration exists but no service principal (Enterprise Application) has been created in the tenant yet. This usually means admin consent has never been granted. Click Grant admin consent for under API permissions. That step creates the service principal as a side effect. **TENANT_ALREADY_BOUND** This M365 tenant is already linked to another Dex organization. Contact your Dex administrator. **Script: Insufficient privileges** The account you signed in with while running Setup-DexTenant.ps1 is not a Global Administrator of this tenant. Sign in with a GA account and re-run the script. **Script: an app named Dex already exists** The script automatically uses the next free name (Dex 2, Dex 3, …) and prints which name it used. You can delete stale Dex apps later in Entra → App registrations. **Script: some permissions show as failed** Usually a replication delay. Open Entra → App registrations → Dex → API permissions, click Grant admin consent, then add the tenant in Dex. If Dex still returns MISSING_PERMISSIONS, wait 1–2 minutes (consent propagation) and click Add Tenant again. ## Rotating the secret later (Automated variant) Client secrets expire. To rotate without downtime: 1. In the app's Certificates & secrets page, create a new client secret. 2. In the Dex MSP dashboard, open the tenant and update its credentials with the new secret Value. 3. Once Dex confirms the new secret works, delete the old secret in Entra. Or create the new secret from PowerShell in the customer tenant (then continue from step 2 above): ``` Connect-MgGraph -Scopes "Application.ReadWrite.All" -NoWelcome $app = Get-MgApplication -Filter "displayName eq 'Dex'" $new = Add-MgApplicationPassword -ApplicationId $app.Id -PasswordCredential @{    DisplayName = "Dex integration (rotated)"    EndDateTime = (Get-Date).AddMonths(24) } $new.SecretText ``` ## Summary checklist (Automated variant) - Ran Setup-DexTenant.ps1 as a Global Administrator of the customer's tenant (Cloud Shell or local PowerShell). - The script finished with admin consent granted for all 27 permissions. - Copied the three printed values: Tenant ID, Client ID, and Client Secret. - Pasted the three values into Dex Add tenant and clicked Add Tenant. --- ## Variant B: Manual, Entra portal ## Before You Start You will need: - A user account with Global Administrator rights in the customer's Microsoft 365 tenant. - Access to the Microsoft Entra admin center (or the Azure portal). - About 10 minutes. ## Step 1: Create the app registration 1. Sign in to https://entra.microsoft.com as a Global Administrator of the customer tenant. 2. In the left menu, go to Identity → Applications → App registrations. 3. Click + New registration. 4. Fill in: - Name: Dex (or any name, only shown to admins inside Entra). - Supported account types: Accounts in this organizational directory only (Single tenant). - Redirect URI: leave blank. 5. Click Register. You are now on the app's Overview page. Keep this tab open. You will copy two values from it shortly. ## Step 2: Copy the Tenant ID and Client ID On the app's Overview page, copy these two values: | FIELD IN ENTRA | PASTE INTO DEX AS | | --- | --- | | Directory (tenant) ID | Tenant ID (first field) | | Application (client) ID | Client ID (second field) | ## Step 3: Create a client secret 1. In the left menu of the app, click Certificates & secrets. 2. Under the Client secrets tab, click + New client secret. 3. Fill in: - Description: Dex integration - Expires: choose the longest option your security policy allows (24 months recommended). You will need to rotate the secret before it expires. 4. Click Add. 5. Immediately copy the Value column (not the Secret ID). This is shown only once. If you navigate away you will need to create a new secret. Paste this value into the Client secret field (third field) in the Dex Add tenant dialog. **Important** Copy the Value, not the Secret ID. The Value is a long string that starts with characters like 6CR8Q~…. The Secret ID is a GUID and will not work. ## Step 4: Grant API permissions This is the most important step. Dex needs a specific set of Microsoft Graph application permissions. If any are missing, the Add tenant validation will fail and tell you exactly which roles still need consent. ### 4a. Add the permissions 1. In the left menu of the app, click API permissions. 2. Click + Add a permission. 3. Choose Microsoft Graph. 4. Choose Application permissions (not Delegated). 5. Search for and add each permission listed below. You can add them in batches: search, tick the checkboxes, and click Add permissions, then repeat. ### 4b. Grant admin consent After all permissions are added: 1. Back on the API permissions page, click Grant admin consent for . 2. Confirm. The Status column should turn into a green check (Granted for ) for every row. ### Required Microsoft Graph application permissions All permissions below are Application type, on the Microsoft Graph API. Dex's validator checks for every one of these. If any are missing, you will get a MISSING_PERMISSIONS error listing exactly which roles still need consent. **Core identity & directory** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | User.ReadWrite.All | Create, update, disable, and delete users; reset passwords; manage licenses. | | Directory.ReadWrite.All | Read and write directory objects (users, groups, devices) for org-wide operations. | | Group.ReadWrite.All | Create and manage Microsoft 365 groups, security groups, and distribution lists. | | GroupMember.ReadWrite.All | Add and remove members from groups. | | UserAuthenticationMethod.ReadWrite.All | Manage MFA methods, register/reset authentication methods. | **Audit & security** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | AuditLog.Read.All | Read sign-in and audit logs for incident investigation. | | Application.Read.All | Read app registrations and service principals during discovery. | | RoleManagement.Read.Directory | Read directory role assignments to evaluate privilege. | | BitlockerKey.Read.All | Retrieve BitLocker recovery keys for device recovery workflows. | **Intune / device management** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | DeviceManagementApps.ReadWrite.All | Manage Intune app deployments. | | DeviceManagementConfiguration.Read.All | Read Intune configuration and compliance policies. | | DeviceManagementManagedDevices.PrivilegedOperations.All | Wipe, retire, remote lock, and reset managed devices. | | DeviceManagementManagedDevices.ReadWrite.All | Read and update managed device records. | **Exchange / mail** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | Mail.Send | Send notification and remediation emails from user mailboxes. | | Mail.ReadWrite | Read and modify mailbox contents during investigation and cleanup. | | Calendars.ReadWrite | Manage calendar events during onboarding/offboarding. | | MailboxSettings.ReadWrite | Configure mailbox settings (forwarding, OOO, delegates). | **SharePoint / files** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | Sites.Read.All | Read SharePoint site metadata for discovery. | | Sites.ReadWrite.All | Manage SharePoint sites and lists. | | Sites.FullControl.All | Required for site provisioning and permission management. | | Files.Read.All | Read OneDrive / SharePoint files for investigation. | | Files.ReadWrite.All | Manage files during offboarding and content cleanup. | **Reports & organization** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | Organization.Read.All | Read tenant info (display name, verified domains, licenses). | | Reports.Read.All | Pull usage and activity reports for posture analysis. | | ReportSettings.ReadWrite.All | Enable de-anonymized reports so user-level usage data is available. | **Teams** | PERMISSION | WHY DEX NEEDS IT | | --- | --- | | TeamsAppInstallation.ReadWriteForUser.All | Install the Dex Teams app for end users. | | AppCatalog.ReadWrite.All | Upload and update the Dex Teams app in the tenant app catalog. | ## Step 5: Add the tenant in Dex 1. Return to the Dex Add tenant dialog. 2. Enter an Organization name (this is the label that will show in your MSP dashboard, it does not need to match the M365 tenant name). 3. Select Microsoft 365. 4. Paste the three values you collected: - Tenant ID → from the app's Overview page - Client ID → from the app's Overview page - Client Secret → the Value you copied in Step 3 5. Click Add Tenant. Dex will: 1. Acquire an app-only token to verify the credentials are valid. 2. Call /organization on Microsoft Graph to confirm the tenant matches. 3. Look up the service principal and list its granted app roles. 4. Compare granted roles against the required list and report any missing ones. If everything succeeds, the tenant appears in your MSP dashboard and Dex automatically starts a discovery scan. ## Troubleshooting (Manual variant) **INVALID_CREDENTIALS** - Double-check you pasted the Tenant ID (not the tenant domain like contoso.onmicrosoft.com). - Confirm the Client Secret is the Value, not the Secret ID. - Confirm the secret has not expired. Go to Certificates & secrets in Entra and check the Expires column. **MISSING_PERMISSIONS** The error response includes the exact list of missing permissions. Go back to API permissions in the app registration, add the missing ones, and click Grant admin consent again. Then retry Add Tenant. **SERVICE_PRINCIPAL_NOT_FOUND** The app registration exists but no service principal (Enterprise Application) has been created in the tenant yet. This usually means admin consent has never been granted. Click Grant admin consent for under API permissions. That step creates the service principal as a side effect. **TENANT_ALREADY_BOUND** This M365 tenant is already linked to another Dex organization. Contact your Dex administrator. ## Rotating the secret later (Manual variant) Client secrets expire. To rotate without downtime: 1. In the app's Certificates & secrets page, create a new client secret. 2. In the Dex MSP dashboard, open the tenant and update its credentials with the new secret Value. 3. Once Dex confirms the new secret works, delete the old secret in Entra. Or create the new secret from PowerShell in the customer tenant (then continue from step 2 above): ``` Connect-MgGraph -Scopes "Application.ReadWrite.All" -NoWelcome $app = Get-MgApplication -Filter "displayName eq 'Dex'" $new = Add-MgApplicationPassword -ApplicationId $app.Id -PasswordCredential @{    DisplayName = "Dex integration (rotated)"    EndDateTime = (Get-Date).AddMonths(24) } $new.SecretText ``` ## Summary checklist (Manual variant) - Registered a new app in Entra → App registrations (Single tenant). - Copied Directory (tenant) ID and Application (client) ID. - Created a Client secret and copied its Value. - Added all required Microsoft Graph application permissions listed above. - Clicked Grant admin consent for the tenant: every row shows a green check. - Pasted the three values into Dex Add tenant and clicked Add Tenant.