Skip to content

Instantly share code, notes, and snippets.

@joerodgers
joerodgers / Get-CopilotCostManagementUserServiceBalance.ps1
Last active October 5, 2026 15:43
Microsoft Graph API calls to list Cost Mgmt. spending policies and user level consumption data.
#requries -modules "Microsoft.Graph.Authentication"
function New-CopilotCostManagementAdminConsentUrl
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[Guid]
$ClientId,
@joerodgers
joerodgers / Set-GHCPHarnessCreditLimits.ps1
Last active September 25, 2026 19:00
Sets credit consumption limits for matched GHCP agents
#requires -modules Az.Accounts
<#
.SYNOPSIS
Sets standard or GHCP harness credit consumption limits for matched Power Platform agents.
.DESCRIPTION
Enumerates Power Platform environments and their GHCP agents reads the current credit limit for each resource, applies the requested limit mode, and writes the results to console and CSV output.
@joerodgers
joerodgers / Add-Dataverse.ps1
Last active September 15, 2026 19:15
Example script that adds dataverse to an existing Power Platform environment
#requries -modules "Az.Accounts"
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]
$ResourceUrl,
@joerodgers
joerodgers / Delete-CopilotStudioAgent.ps1
Created September 11, 2026 17:48
Example script for how to delete a Copilot Studio agent via Power Platform REST API
#requries -modules "Az.Accounts"
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[Guid]
$ClientId,
@joerodgers
joerodgers / BillingPolicyResourceGroupDetail.ps1
Created September 8, 2026 20:03
Example script that pulls Power Platform billing policies and the associated Azure Resource Group "CostCenter" tag value
#requries -modules "Az.Accounts"
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]
$ResourceUrl
@joerodgers
joerodgers / Get-AgentCreditConsumptionLimit.ps1
Last active September 2, 2026 19:03
Example script using the Upsert Resource Threshold Power Platform API for setting agent level credit consumption limits.
#requries -modules "Az.Accounts"
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]
$ResourceUrl
@joerodgers
joerodgers / Get-PowerPlatformResourceMessageConsumption.ps1
Last active September 28, 2026 15:24
Example how to query resource (agents and workflows) Copilot credit consumption for a given time period.
#requries -modules "Az.Accounts"
class PowerPlatformResource
{
[string]
$ResourceType
[string]
$ResourceName
@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]