name: powerplatform-dashboard description: >- Builds a single self-contained interactive HTML dashboard analyzing a Power Platform tenant from two exports — an environment report and an agent inventory. Use when the user says "build a Power Platform dashboard", "analyze my Power Platform environments", "Power Platform environment + agent report", "Copilot Studio / Agent Builder agent analytics", "dashboard from my environment and agent exports", or attaches a PowerPlatformEnvironmentReport plus an agent-inventory file and asks for analytics. Do NOT use for generic spreadsheet charts, non-Power-Platform data, building Power BI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requries -modules "Microsoft.Graph.Authentication" | |
| # requires Microsoft Graph > Application > CopilotPackages.Read.All | |
| Connect-MgGraph -ClientId $env:CDX_CLIENTID -CertificateThumbprint $env:CDX_THUMBPRINT -TenantId $env:CDX_TENANTID | |
| $uri = "v1.0/copilot/admin/catalog/packages" | |
| $results = do | |
| { | |
| $response = Invoke-MgGraphRequest -Method GET -Uri $uri -OutputType PSObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Az.Accounts" | |
| function Get-AccessToken | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [Parameter(Mandatory=$true)] | |
| [string] | |
| $ResourceUrl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Az.Accounts" | |
| #requires -version "7.0" | |
| function Get-AccessToken | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [Parameter(Mandatory=$true)] | |
| [string] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ******* | |
| Write-Host "Creating Token" | |
| $uri = "https://directline.botframework.com/v3/directline/tokens/generate" | |
| $secret = "....." | |
| $headers = @{ Authorization = "Bearer $secret" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Microsoft.Graph.Authentication" | |
| # the agent inventory API is gated behind the A365 license, so user identity needs an A365 license assigned. | |
| # Connect-MgGraph -Scopes "CopilotPackages.Read.All" -ClientId $env:O365_CLIENTID | |
| # as of 8/6/26 this works with application permissions, still need the "CopilotPackages.Read.All" scope!!! | |
| Connect-MgGraph -ClientId $env:CDX_CLIENTID -CertificateThumbprint $env:CDX_THUMBPRINT -TenantId $env:CDX_TENANTID | |
| $uri = "v1.0/copilot/admin/catalog/packages" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Microsoft.PowerApps.Administration.PowerShell" | |
| function Register-PowerPlatformAdminServicePrincipal | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [Parameter(Mandatory=$true)] | |
| [Guid] | |
| $ClientId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Microsoft.PowerApps.Administration.PowerShell" | |
| function Get-AgentInventory | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| ) | |
| begin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Microsoft.Graph.Authentication" | |
| # permissions: Microsoft Graph > Application > AgentInstance.Read.All | |
| Connect-MgGraph -ClientId $env:CDX_CLIENTID -CertificateThumbprint $env:CDX_THUMBPRINT -TenantId $env:CDX_TENANTID | |
| $uri = "/beta/agentRegistry/agentInstances" | |
| $mcsAgents = do | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -modules "Microsoft.PowerApps.Administration.PowerShell" | |
| function Get-BillingPolicyEnvironmentMap | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| ) | |
| begin |
NewerOlder