This project pulls usage and inventory data for:
- Copilot Studio agents and conversation analytics
- SharePoint agents (
.agentfiles) - Optional M365 Copilot Agent Builder package metadata
The scripts authenticate with a service principal (SPN), call Microsoft APIs, and write JSON/CSV/TXT outputs under Data/CopilotStudio.
bot usage analytics.py is for the Azure Search OpenAI Demo that Microsoft suggested before Copilot Studio/Agents emerged. Works for CosmosDB exports based on conversation history that is provisioned in the old Azure AI Studio > chat playground > deploy web app. Feel free to ignore bot usage analytics.py
Fetch - CopilotStudio.ps1- Reads bots and conversation transcript analytics from configured Copilot Studio environments.
Fetch - SharePointAgents.ps1- Connects to SharePoint Online and finds
.agentfiles via search.
- Connects to SharePoint Online and finds
Fetch - M365CopilotAgents.ps1- Calls Graph beta endpoints for Copilot admin package metadata (optional).
Fetch-Run.ps1- Orchestrator that reads
Config.jsonand runs selected scripts.
- Orchestrator that reads
- PowerShell 7+
- Entra app registration (service principal) with client secret
- Required API permissions granted and admin consented
PnP.PowerShellmodule for SharePoint script:
Install-Module -Name PnP.PowerShell -Scope CurrentUser -Force -AllowClobberUse application permissions (not delegated) for the SPN.
- Copilot Studio / Power Platform permissions:
TenantRead.AllCopilotStudio.ReadAll
- Microsoft Graph permissions (needed by
Fetch - M365CopilotAgents.ps1):AgentCollection.Read.AllAgentInstance.Read.AllCopilotPackages.Read.All
- SharePoint access:
- App-only access to your SharePoint tenant and permissions sufficient to query/search sites with agent files.
- In many tenants this is configured with Sites read-level access plus appropriate admin approvals.
After adding permissions, grant admin consent in Entra before running the scripts.
Update Config.json with your tenant values. Keep real secrets out of source control.
{
"OutputPath": ".\\Data",
"ServicePrincipal": {
"ClientId": "<app-id>",
"ClientSecret": "<client-secret>",
"TenantId": "<tenant-id>",
"Environment": "Public"
},
"CopilotStudio": {
"StartDate": null,
"EndDate": null,
"Environments": [
{
"Name": "<environment-name>",
"EnvironmentId": "<environment-id>",
"EnvironmentUrl": "<environment-hostname-without-https>"
}
]
},
"SharePoint": {
"ClientId": "<optional-dedicated-sharepoint-app-id>",
"ClientSecret": "<optional-dedicated-sharepoint-secret>",
"TenantAdminUrl": "https://<tenant>-admin.sharepoint.com"
}
}Run all enabled collectors:
./Fetch-Run.ps1If script execution is blocked by policy, run with a temporary bypass for the current PowerShell process:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
./Fetch-Run.ps1Or run in one command:
powershell -ExecutionPolicy Bypass -File .\Fetch-Run.ps1Run with explicit config path:
./Fetch-Run.ps1 -configFilePath .\Config.jsonRun one script directly:
./"Fetch - CopilotStudio.ps1" -config (Get-Content .\Config.json | ConvertFrom-Json)The scripts generate report files in Data/CopilotStudio, including:
Agents.json,Analytics.jsonSharePointAgents.json,SharePointAgents-Report.csv,SharePointAgents-Report.txtM365CopilotAgents.json,M365CopilotAgents-Report.csv,M365CopilotAgents-Report.txt
- Do not commit live client secrets to git.
- Prefer a local
Config.jsonwith placeholder template values in shared repos. - Review generated output before sharing, as reports may contain internal names, URLs, and user metadata.