> For the complete documentation index, see [llms.txt](https://docs.autopilotmonitor.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.autopilotmonitor.com/reference/optional-graph-permissions.md). Agents can also search and read this documentation through its [MCP server](https://docs.autopilotmonitor.com/~gitbook/mcp).

# Optional Graph Permissions

Opt-in tenant-side Microsoft Graph permissions for optional features via appRoleAssignment, without changing the published app manifest, and how to revoke them.

Autopilot Monitor's default Microsoft Graph permissions are intentionally minimal — they cover Autopilot device, corporate identifier and device association validation, including the Autopilot registration details a session keeps, and nothing more (see [Portal Setup](https://docs.autopilotmonitor.com/getting-started/portal-setup.md) and the [Settings Reference](https://docs.autopilotmonitor.com/reference/settings.md)). Some optional features need additional permissions on the Autopilot Monitor service principal **in your tenant**. Examples:

| Feature                 | Description                                                                                                                                                                                                                                                                                                                               | Required Graph permission                 |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| `ScriptDisplayNames`    | Resolves Intune Platform Script + Remediation Script display names in session timelines                                                                                                                                                                                                                                                   | `DeviceManagementScripts.Read.All`        |
| `W365CloudPcValidation` | Validates [Windows 365 Cloud PCs](https://docs.autopilotmonitor.com/getting-started/windows-365-cloud-pcs.md) against the tenant's Cloud PC inventory — Cloud PCs are never Autopilot-registered, so this enables monitoring of Cloud PC first-connect enrollment                                                                         | `CloudPC.Read.All`                        |
| `IntuneDeviceBinding`   | Backs **Intune Enrollment Validation**: accepts devices enrolled in your tenant's Intune without any pre-registration, matched by the Intune device id from the device's MDM certificate (see [Autopilot Device Preparation](https://docs.autopilotmonitor.com/getting-started/autopilot-device-preparation.md#without-pre-registration)) | `DeviceManagementManagedDevices.Read.All` |

The **Feature** column values are exactly what the grant script's `-Features` parameter accepts; the meta-value `All` selects every feature in the table at once.

Rather than baking these permissions into the published app manifest (which would force every customer to consent to them at first sign-up, even the ones who'll never use the feature), Autopilot Monitor offers them as **opt-in tenant-side grants**. You decide per feature, you grant only what you need.

## How it works

The grant happens through a **tenant-local `appRoleAssignment`** on the Autopilot Monitor service principal that already lives in your tenant after the initial admin consent. This is supported by Microsoft Graph and does **not** change the publisher's app manifest — the extra capability exists only for your tenant.

Behind the scenes:

1. You download and run the `Grant-AutopilotMonitorAddOn.ps1` helper script (see [Downloading the script](#downloading-the-script) below) with a tenant-admin sign-in.
2. The script finds the Autopilot Monitor service principal in your tenant by its application (client) ID.
3. The script reads the requested feature(s), translates them to the underlying Graph permission(s), and creates a fresh `appRoleAssignment` for each — or skips it if already granted.
4. The next time the Autopilot Monitor backend acquires a token for your tenant, Azure AD includes the new permissions in the `roles` claim. The backend uses that claim to enable or disable optional features per tenant — no further configuration on your side.

## Prerequisites

* The Autopilot Monitor multi-tenant app must already be admin-consented in your tenant. Without that, the service principal doesn't exist yet and the script has nothing to grant against.
* The signed-in admin needs **Global Administrator** or **Privileged Role Administrator** (PIM/JIT users: activate the role first). Only these roles can grant Microsoft Graph application permissions; **Application Administrator** and **Cloud Application Administrator** cannot.
* The `Microsoft.Graph.Authentication` PowerShell module. The script auto-installs it for the current user if missing.

## Downloading the script

The script is published on the Autopilot Monitor download host, next to the agent artifacts — download it directly ([Grant-AutopilotMonitorAddOn.ps1](https://download.autopilotmonitor.com/agent/Grant-AutopilotMonitorAddOn.ps1)) or fetch it from a PowerShell prompt:

```powershell
irm 'https://download.autopilotmonitor.com/agent/Grant-AutopilotMonitorAddOn.ps1' -OutFile .\Grant-AutopilotMonitorAddOn.ps1
```

## Running the script

{% hint style="info" %}
The easiest path is to open the admin UI in Autopilot Monitor → **Settings → Optional Graph capabilities**, tick the features you want in the capability table, hit **Copy command**, and paste the resulting PowerShell into Azure Cloud Shell or a PS prompt. The command follows your selection — ticking every feature switches it to `-Features All` — downloads the script and runs it, with the ClientId pre-filled with the live value for your environment. **Copy permissions** copies the raw permission strings for the same selection.
{% endhint %}

{% hint style="success" %}
**Azure Cloud Shell** is the smoothest place to run the script. There it signs in through the ambient Cloud Shell identity — a delegated token for the admin already signed in to the portal — so no separate sign-in prompt appears and no device-code flow is involved (device-code sign-ins are blocked by Conditional Access in many tenants). Outside Cloud Shell the script automatically falls back to a normal interactive Microsoft Graph sign-in.
{% endhint %}

If you prefer the high-level feature form:

```powershell
.\Grant-AutopilotMonitorAddOn.ps1 `
    -ClientId "<the-autopilot-monitor-app-id>" `
    -Features ScriptDisplayNames
```

To grant several features at once, pass them as a comma-separated list:

```powershell
.\Grant-AutopilotMonitorAddOn.ps1 -ClientId "<...>" -Features ScriptDisplayNames,W365CloudPcValidation
```

To grant **every** optional capability in one run, use the `All` meta-feature — it expands to all features in the table above:

```powershell
.\Grant-AutopilotMonitorAddOn.ps1 -ClientId "<...>" -Features All
```

Other modes:

```powershell
# Read-only inspection of currently granted permissions on the SP:
.\Grant-AutopilotMonitorAddOn.ps1 -ClientId "<...>" -Features ScriptDisplayNames -VerifyOnly

# Revoke a previously granted feature:
.\Grant-AutopilotMonitorAddOn.ps1 -ClientId "<...>" -Features ScriptDisplayNames -Revoke

# Revoke all optional grants at once:
.\Grant-AutopilotMonitorAddOn.ps1 -ClientId "<...>" -Features All -Revoke
```

After granting, return to the admin UI and click **Refresh permission status**. The backend caches its token (and the `roles` claim parsed from it) for up to \~1 hour; the refresh button clears that cache so the new permission takes effect immediately.

## What the script does NOT do

* It does **not** change the published Autopilot Monitor app manifest.
* It does **not** touch any other Entra application or service principal.
* It does **not** persist credentials anywhere; the only thing it writes is one or more `appRoleAssignment` rows on the Autopilot Monitor service principal in your tenant.

## Auditability

Granted permissions show up in the Entra portal under **Enterprise applications → Autopilot Monitor → Permissions → "Other granted permissions"**. They also appear in the Microsoft Graph API at `GET /servicePrincipals/{sp}/appRoleAssignments` — both during normal operation and in compliance audits. The Autopilot Monitor admin UI surfaces the same view at **Settings → Optional Graph capabilities**.

## Revoking

Use the script's `-Revoke` flag, or remove the assignment manually in the Entra portal. The admin UI **Refresh permission status** button will pick up the change on the next backend call.

## Troubleshooting

| Symptom                                                                                                                             | Likely cause                                                                                                                                                                                                                                                                                                 |
| ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Script errors with `Service principal not found`                                                                                    | The Autopilot Monitor app has never been admin-consented in your tenant. Run the consent flow first.                                                                                                                                                                                                         |
| `AppRoleAssignment.ReadWrite.All` was NOT granted in the sign-in scopes line (interactive sign-in)                                  | Signed-in user lacks one of the required admin roles. PIM/JIT users: activate the eligible role before running the script.                                                                                                                                                                                   |
| A grant or revoke fails with `Forbidden` or `Authorization_RequestDenied: Insufficient privileges to complete the operation.` (403) | The signed-in account may not manage Microsoft Graph application permissions (for example Application Administrator, Cloud Application Administrator or Intune Administrator). Sign in as Global Administrator or Privileged Role Administrator (PIM/JIT: activate the role first) and run the script again. |
| Interactive sign-in is blocked by Conditional Access (device-code flow)                                                             | Run the script in Azure Cloud Shell — it uses the ambient Cloud Shell identity and needs no device-code sign-in.                                                                                                                                                                                             |
| Permission shows as granted in the UI but the backend still sees it as not granted                                                  | The backend's per-tenant token cache hasn't refreshed yet. Click **Refresh permission status** in the admin UI.                                                                                                                                                                                              |
| **Settings → Autopilot Validation** shows **Permission missing** below Cloud PC or Intune Enrollment Validation                     | The validation is on, but its feature is not granted yet. Grant it, or turn the validation off. See [Device Validation: Permission Missing](https://docs.autopilotmonitor.com/troubleshooting-and-support/device-validation-permission-missing.md).                                                          |
| Permission grant succeeds but the optional feature still doesn't activate                                                           | Verify the granted permission via `Get-MgServicePrincipalAppRoleAssignment` and recheck the admin UI status panel. If still inconsistent, send the correlation IDs from the relevant calls to support.                                                                                                       |
| A renamed script still shows its old name in a session                                                                              | Script names are cached for about a week, so a rename can take that long to appear. New scripts show their name right away.                                                                                                                                                                                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.autopilotmonitor.com/reference/optional-graph-permissions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
