Skip to content

Instantly share code, notes, and snippets.

#requires -module "Microsoft.PowerApps.Administration.PowerShell"
$requestBody = @{
powerPlatform = @{
powerApps = @{
enableManagedAppsMcsPreview = "Off"
enableManagedAppsCliPreview = "Off"
}
}
}
@joerodgers
joerodgers / Invoke-CreditConsumptionReportDownload.ps1
Last active October 15, 2026 19:02
Downloads a Copilot credit consumption from Power Platform using the new private preview APIs.
#requires -modules Az.Accounts
function Get-AccessToken
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string]
$ResourceUrl,
#requries -modules "Microsoft.Graph.Authentication"
function Get-PendingCopilotPackage
{
[CmdletBinding()]
param
(
)
begin
@joerodgers
joerodgers / Get-CopilotCostManagementUserServiceBalance.ps1
Last active October 9, 2026 17:21
Microsoft Graph API calls to list Cost Mgmt. spending policies and user level consumption data.
#requries -modules "Microsoft.Graph.Authentication"
function Get-CopilotCostManagementTenantCreditBalance
{
[CmdletBinding()]
param
(
)
begin
@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
Last active October 20, 2026 08:56
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