This is a PowerShell sample that gathers Microsoft 365 Copilot enterprise
interaction history straight from the Microsoft Graph API and renders a
single, self-contained HTML dashboard — no Power BI, no database, no extra
infrastructure. Just run the script and open the resulting .html file in a
browser.
Unlike the Power BI samples in this folder (which build on Viva Insights or
Purview Audit exports), this sample reads the
getAllEnterpriseInteractions
Graph endpoint directly, so it reflects the actual Copilot prompts and responses
recorded for each licensed user. The report shows:
- Headline stats — active users, total licensed users, interactions, sessions
- Copilot events over time, broken down by the top surfaces (a line chart)
- App / # Users / # Actions — which Copilot surfaces are being used
- Top users with a per-surface interaction breakdown
- Friction — users with the highest AI-response error rates
- Usage by app feature — prompt intent classified by keyword patterns (Summarize, Draft, Search, Analyze, …)
- A sortable All Users leaderboard
- Audited events — the most recent prompts with snippets
The dataset shown in the recording above is fictional sample data.
| Script | Role |
|---|---|
CopilotAnalytics.psm1 |
Module with the reusable functions: New-GraphContext, Export-CopilotInteractions, Build-CopilotReport. |
New-CopilotInteractionReport.ps1 |
Entry-point orchestrator. Authenticates, exports per-user JSON, then builds the HTML report. |
- Export —
Export-CopilotInteractionsauthenticates app-only to Graph, enumerates enabled users assigned the Copilot SKU, and pulls each user's interaction history into<safe-upn>.json(plus_users.jsonand_summary.json). Existing files act as a cache and are skipped. - Report —
Build-CopilotReportaggregates those JSON files and writes a self-containedcopilot-report.html(the only external dependency is the Chart.js CDN script used for the trend chart).
- PowerShell 7+ (
pwsh). - An Entra ID app registration with the following Microsoft Graph
application permissions, with admin consent granted:
AiEnterpriseInteraction.Read.AllUser.Read.AllOrganization.Read.All
- A client secret or a certificate for that app registration.
- Users licensed for Microsoft 365 Copilot (SKU
639dec6b-bb19-468b-871c-c5c441c4b0cbby default — find others viaGET /v1.0/subscribedSkus).
- In the Entra admin center, go to App registrations → New registration. Give it a name and register it.
- Under API permissions → Add a permission → Microsoft Graph → Application permissions, add the three permissions listed above, then click Grant admin consent.
- Under Certificates & secrets, create either a client secret or upload a certificate.
- Copy the Directory (tenant) ID and Application (client) ID from the app's Overview page.
From this folder, in a PowerShell 7 session:
# Client-secret auth, last 30 days, all licensed users
.\New-CopilotInteractionReport.ps1 `
-TenantId <tenant-id> `
-ClientId <client-id> `
-ClientSecret <secret-value> `
-SinceDays 30# Certificate auth from the Windows certificate store
.\New-CopilotInteractionReport.ps1 `
-TenantId <tenant-id> `
-ClientId <client-id> `
-CertificateThumbprint <thumbprint> `
-SinceDays 30# Certificate auth from a .pfx file
$pw = Read-Host -AsSecureString "PFX password"
.\New-CopilotInteractionReport.ps1 `
-TenantId <tenant-id> -ClientId <client-id> `
-CertificatePath .\app.pfx -CertificatePassword $pwYou can also supply credentials via the AZURE_TENANT_ID, AZURE_CLIENT_ID,
and AZURE_CLIENT_SECRET environment variables instead of parameters.
When it finishes, the report (copilot-report.html) opens automatically in your
default browser. Pass -NoLaunch to suppress this.
| Parameter | Description | Default |
|---|---|---|
-SinceDays |
Only include interactions newer than N days (0 = no filter). |
7 |
-SkuId |
License SKU to enumerate. | M365 Copilot |
-MaxUsers |
Cap the number of users (handy for a quick test). | 0 (all) |
-DataDir |
Folder for the per-user JSON export. | .\data\interactions |
-OutputPath |
Path of the HTML report to write. | .\copilot-report.html |
-SkipExport |
Skip the Graph export and rebuild the report from existing JSON. | off |
-NoLaunch |
Don't open the report in the browser when finished. | off (opens) |
.\New-CopilotInteractionReport.ps1 -SkipExport -DataDir .\data\interactions- Copilot Studio agents (declarative / custom agents invoked from Copilot Chat) do not register with the Graph interaction-history API this report is built on, so their usage is not reflected in the counts.
- Interaction history can contain prompt and response content. Treat the exported JSON and the generated report as sensitive, and handle them in line with your organization's data-privacy and governance policies.
| Author | Original Publish Date |
|---|---|
| Dean Cron, Microsoft | June 2026 |
Please report any issues you find to the issues list.
The scripts, samples, and tools made available through the FastTrack Open Source initiative are provided as-is. These resources are developed in partnership with the community and do not represent official Microsoft software. As such, support is not available through premier or other Microsoft support channels. If you find an issue or have questions please reach out through the issues list and we'll do our best to assist, however there is no associated SLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Microsoft and any contributors grant you a license to the Microsoft documentation and other content in this repository under the MIT License, see the LICENSE file, and grant you a license to any code in the repository under the MIT License, see the LICENSE-CODE file.
Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.
Privacy information can be found at https://privacy.microsoft.com/en-us/
Microsoft and any contributors reserve all others rights, whether under their respective copyrights, patents,or trademarks, whether by implication, estoppel or otherwise.
