> ## Documentation Index
> Fetch the complete documentation index at: https://university.triggr-app.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Exchange

> Let Triggr run Exchange Online PowerShell in your clients' Microsoft 365 tenants, signed in as Triggr's own Microsoft app.

Triggr runs Exchange Online PowerShell in your clients' tenants as its own Microsoft app, for shared mailboxes, out-of-office replies, mailbox permissions, distribution groups and your own cmdlets. Microsoft 365 steps use it through GDAP or SAM; steps that run through [CIPP](/integrations/cipp) use CIPP instead.

In each tenant, Triggr's app (`e0ce32ae-7ba3-4f66-b686-d22dd0eb7841`) needs Exchange.ManageAsApp on Office 365 Exchange Online and the Exchange Administrator role. See Microsoft's [app-only authentication](https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps).

## Set up Exchange for GDAP clients

For clients linked through [Microsoft Graph (GDAP)](/integrations/microsoft-graph/gdap-service-account), Triggr does this itself, as long as Triggr's security group has Privileged Role Administrator in their GDAP relationships.

<Steps>
  <Step title="Link the client">
    Linking a client through Microsoft Graph (GDAP) creates its Exchange configuration from its default verified domain, saved as its `microsoftTenantDomain` variable. If that didn't happen, Triggr tries again the first time an Exchange step runs for the client.
  </Step>

  <Step title="Run Repair">
    Open the client from Clients and click **Repair** on its GDAP Health card, if shown. It grants Exchange.ManageAsApp, assigns Exchange Administrator and adds any missing configuration.

    <Frame caption="A client's GDAP Health card in Triggr Core.">
      <img src="https://mintcdn.com/triggr/MwzXHG3UWzFixdSz/images/core/add-your-clients/gdap-health.png?fit=max&auto=format&n=MwzXHG3UWzFixdSz&q=85&s=15946d35b88336c73e7719d95c3f8efe" alt="GDAP health showing App not consented with Repair and Check now buttons, and checks for Microsoft sign-in, Graph permissions, Admin roles, GDAP relationship and Recent failures." width="1340" height="1050" data-path="images/core/add-your-clients/gdap-health.png" />
    </Frame>
  </Step>
</Steps>

## Connect it in Triggr

To add or fix a client's configuration yourself:

<Steps>
  <Step title="Open the client's row">
    Go to **Integrations > Microsoft Exchange** and click Configure (or Edit) on the client's row in the Per-Client Configuration card.

    <Frame>
      <img src="https://mintcdn.com/triggr/nyuVXZ1rouDTTEvu/images/integrations-common/per-client-configuration.png?fit=max&auto=format&n=nyuVXZ1rouDTTEvu&q=85&s=11464b4946bea0b580c73330d9114a41" alt="The Per-Client Configuration card listing Acme Corp and Globex, each Not Configured with Admin Consent Not Required and a Configure button." width="2272" height="646" data-path="images/integrations-common/per-client-configuration.png" />
    </Frame>
  </Step>

  <Step title="Enter the client's domain">
    Leave ClientID as `e0ce32ae-7ba3-4f66-b686-d22dd0eb7841`, enter a domain of the client's tenant in MicrosoftTenantDomain without `https://` (ideally its `.onmicrosoft.com` domain), and click Save Configuration.

    <Frame>
      <img src="https://mintcdn.com/triggr/nyuVXZ1rouDTTEvu/images/microsoft-exchange/configure.png?fit=max&auto=format&n=nyuVXZ1rouDTTEvu&q=85&s=6411f36542b0ace3c3d4cf7fcbe6048a" alt="The Microsoft Exchange configuration window with ClientID already filled in (blurred), an empty MicrosoftTenantDomain field, an Allow insecure TLS switch under Advanced, and a Save Configuration button." width="1344" height="1126" data-path="images/microsoft-exchange/configure.png" />
    </Frame>
  </Step>
</Steps>

Triggr saves the domain as the client's `microsoftTenantDomain` variable. For many clients, click **Automap**, then Approve All; clients without that variable are skipped. Per-client integrations never fall back to the Base Configuration when a workflow runs for a client.

To use Exchange in your own tenant, for workflows without a client, enter your own domain on the Base Configuration card and [grant Exchange access yourself](#grant-exchange-access-yourself).

## Grant Exchange access yourself

Use this in your own tenant, or when Repair can't. Triggr's app must already be in the tenant: GDAP consent adds it to a client's, and Admin Consent on the Microsoft Graph (GDAP) Base Configuration adds it to yours (check under **Entra ID > Enterprise apps > All applications**, with Application Type set to All applications, by searching for `e0ce32ae`). Sign in to [Microsoft Graph PowerShell](https://learn.microsoft.com/en-us/powershell/microsoftgraph/installation) as a Privileged Role Administrator or Global Administrator and run this, replacing `<tenant-id>`:

```powershell theme={null}
Connect-MgGraph -TenantId "<tenant-id>" -Scopes "AppRoleAssignment.ReadWrite.All","Application.Read.All","RoleManagement.ReadWrite.Directory"

# Triggr's app and Exchange Online in this tenant
$triggr = Get-MgServicePrincipal -Filter "appId eq 'e0ce32ae-7ba3-4f66-b686-d22dd0eb7841'"
$exo = Get-MgServicePrincipal -Filter "appId eq '00000002-0000-0ff1-ce00-000000000000'"
$manageAsApp = $exo.AppRoles | Where-Object { $_.Value -eq "Exchange.ManageAsApp" }

# Grant Exchange.ManageAsApp to Triggr's app
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $triggr.Id -BodyParameter @{
  principalId = $triggr.Id
  resourceId  = $exo.Id
  appRoleId   = $manageAsApp.Id
}

# Assign Exchange Administrator (role template 29232cdf-9323-42fd-ade2-1d097af3e4de) to Triggr's app
New-MgRoleManagementDirectoryRoleAssignment -DirectoryScopeId "/" -PrincipalId $triggr.Id -RoleDefinitionId "29232cdf-9323-42fd-ade2-1d097af3e4de"
```

Or assign the role in the admin centre: **Entra ID > Roles & admins > Exchange Administrator > Add assignments**, select Triggr's app and click Add.

## Run your own cmdlets

Run Cmdlet runs the PowerShell in `script` in the client's tenant (or yours, without a client) and returns its output as JSON in `body.output`. Add `-ErrorAction Stop` to fail the step on an error, and return only the properties you need:

```powershell theme={null}
Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize 200 | Select-Object DisplayName,PrimarySmtpAddress
```

Microsoft doesn't allow `New-UnifiedGroup`, `Remove-UnifiedGroup`, `Add-UnifiedGroupLinks` or `Remove-UnifiedGroupLinks` with this sign-in; use Triggr's Microsoft 365 group steps.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Microsoft Exchange integration is not configured for tenant">
    The client has no configuration, or no MicrosoftTenantDomain. Configure it, run Automap, or click **Repair** on its GDAP Health card.
  </Accordion>

  <Accordion title="Failed to connect to Exchange Online">
    Check MicrosoftTenantDomain is the client's domain (try its `.onmicrosoft.com` one) and ClientID is Triggr's app. Then click Repair, or [grant Exchange.ManageAsApp yourself](#grant-exchange-access-yourself).
  </Accordion>

  <Accordion title="Exchange steps fail with a permission error">
    Triggr's app lacks Exchange Administrator in that tenant. Click Repair, or [assign it yourself](#grant-exchange-access-yourself).
  </Accordion>

  <Accordion title="Repair can't assign Exchange Administrator">
    Add Privileged Role Administrator to the client's GDAP relationship for Triggr's security group and run Repair again, or [grant access yourself](#grant-exchange-access-yourself).
  </Accordion>

  <Accordion title="MicrosoftTenantDomain is a Microsoft tenant ID, not a domain">
    The configuration holds a GUID. Click **Edit** on the client's row and enter a domain of its tenant, such as `contoso.onmicrosoft.com`, or click Repair to correct it.
  </Accordion>

  <Accordion title="Triggr's app isn't in this client's tenant yet, or Microsoft is still applying Triggr's new consent">
    Grant Triggr's consent from the client's GDAP Health card, wait a couple of minutes, then click Repair again. "Another Microsoft setup check for this client is still running" means the same: wait a few minutes and retry.
  </Accordion>

  <Accordion title="Exchange Online isn't set up in this client's tenant">
    Triggr couldn't find Exchange Online there. Check the client has a Microsoft 365 subscription that includes Exchange Online.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.