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
| #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 | |
| $uri = "beta/copilot/admin/catalog/packages" | |
| $declarativeAgents = 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 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 |
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
| using Newtonsoft.Json; | |
| using System.Net; | |
| using System.Security.Cryptography; | |
| using System.Text; | |
| public class Script : ScriptBase | |
| { | |
| public override async Task<HttpResponseMessage> ExecuteAsync() | |
| { | |
| // Check if the operation ID matches what is specified in the OpenAPI definition of the connector |
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
| function ConvertFrom-Base64Url | |
| { | |
| param | |
| ( | |
| [Parameter(Mandatory = $true)] | |
| [string] | |
| $InputString, | |
| [Parameter(Mandatory = $false,ParameterSetName="AsString")] |
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" | |
| $clientId = $env:CDX_CLIENTID | |
| $tenantId = $env:CDX_TENANTID | |
| [string[]]$scopes = "https://api.powerplatform.com/.default", "openid", "profile offline_access" | |
| $pca = [Microsoft.Identity.Client.PublicClientApplicationBuilder]::Create($clientId).WithAuthority( "https://login.microsoftonline.com/$tenantId", $true). | |
| WithRedirectUri( "http://localhost" ). | |
| Build() |
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" | |
| function Invoke-GraphThreatHuntingQuery | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [Parameter(Mandatory=$true)] | |
| $HuntingQuery, |
NewerOlder