Skip to content

Instantly share code, notes, and snippets.

@joerodgers
joerodgers / Get-CopilotAgentInventory.ps1
Created August 7, 2026 15:58
Uses the Graph API copilot/admin/catalog/packages endpoint to report all MCS and Agent Builder agents.
#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
@joerodgers
joerodgers / Get-AgentUserPromptMetadata.ps1
Created August 5, 2026 18:47
Reports number of prompts sent to an MCS agent by an Entra user, per day. This requires the user running the script to have read permissions to the conversationtranscript table in all environments being scanned.
#requires -modules "Az.Accounts"
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]
$ResourceUrl
@joerodgers
joerodgers / Get-CopilotStudioAgentInventory.ps1
Last active July 31, 2026 20:48
Temp script to report both standard and modern agents in MCS.
#requires -modules "Az.Accounts"
#requires -version "7.0"
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]
@joerodgers
joerodgers / Test-DirectLineEndpoint.ps1
Last active July 15, 2026 19:39
A direct line script for a smoke test
# *******
Write-Host "Creating Token"
$uri = "https://directline.botframework.com/v3/directline/tokens/generate"
$secret = "....."
$headers = @{ Authorization = "Bearer $secret" }
@joerodgers
joerodgers / powerplatform-dashboard-SKILL.md
Last active June 24, 2026 17:37
Copilot Cowork Power Platform Analytics Dashboard Generation Skill

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

@joerodgers
joerodgers / Get-DeclarativeAgentMetadata.ps1
Last active August 6, 2026 17:34
Uses the agent inventory API to export the metadata about all declarative agents in the tenant to a csv file.
#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"
#requires -modules "Microsoft.PowerApps.Administration.PowerShell"
function Register-PowerPlatformAdminServicePrincipal
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[Guid]
$ClientId
@joerodgers
joerodgers / Get-AgentInventory.ps1
Last active August 6, 2026 17:26
Uses a resource query to pull back all Copilot Studio and Agent Builder agents in the tenant.
#requires -modules "Microsoft.PowerApps.Administration.PowerShell"
function Get-AgentInventory
{
[CmdletBinding()]
param
(
)
begin
#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
{
@joerodgers
joerodgers / Get-PowerPlatformEnvironmentReport.ps1
Last active June 5, 2026 18:05
Creates a report mapping Power Platform environments to billing policies. Includes PAYGO details of each billing policy.
#requires -modules "Microsoft.PowerApps.Administration.PowerShell"
function Get-BillingPolicyEnvironmentMap
{
[CmdletBinding()]
param
(
)
begin