$ pac --version

The Power Platform Admin Job, Run Entirely From a Terminal

Every task a Power Platform admin does in the admin center has a pac or PowerShell equivalent — usually a faster, scriptable, and auditable one. This guide is organized by what you're trying to do (provision an environment, lock down a DLP policy, audit licensing spend) rather than by command group, so you can go from "I need to do X" straight to a working command. For full flag-by-flag syntax on any command, cross-reference the PAC CLI Cheat Sheet — this guide focuses on when and why, not just what.

pac CLI v2.12+ PowerShell 7 Zero admin-center clicks Scriptable & auditable CI/CD-ready
01

Setup & Authentication

Install once, update forever

PowerShell
PS> winget install Microsoft.PowerAppsCLI PS> pac install latest # run this monthly — new admin command groups ship often PS> pac --version
No-install option: with .NET 10+ installed, run any command without a global install via dnx Microsoft.PowerApps.CLI.Tool --yes <command> — useful on a jump box or CI agent you don't want to permanently modify.

Authentication profiles — the admin's identity model

An admin typically juggles several tenants and environments. pac auth profiles let you store all of them and switch instantly instead of re-authenticating.

Create and switch profiles
# One profile per environment you administer — name them meaningfully PS> pac auth create --environment "https://contoso-prod.crm.dynamics.com" --name "Prod" PS> pac auth create --environment "https://contoso-dev.crm.dynamics.com" --name "Dev" # See every stored profile, switch active one, confirm who/where you are PS> pac auth list PS> pac auth select --index 1 PS> pac auth who

Unattended / CI auth (service principal)

For scheduled scripts (the Playbooks section below) or CI/CD, don't authenticate interactively — use a service principal so the script runs unattended.

Service principal auth
# One-time: register the app + create an application user in the environment PS> pac admin create-service-principal --environment <environment-id> # In the scheduled task / pipeline: authenticate non-interactively PS> pac auth create --environment <url> --applicationId <app-id> --clientSecret $env:PAC_SECRET --tenant <tenant-id>
Least privilege matters here. A service principal used for read-only auditing (Playbook 3 below) doesn't need System Administrator — assign it the narrowest security role that covers the commands it actually runs. pac admin create-service-principal grants broad access by default; tighten it with pac admin assign-user and a custom role if the script only reads data.

GCC / GCC High / DoD

Government cloud tenants need the --cloud flag on pac auth create, and interactive sign-in may not work from a restricted network — fall back to device code.

Gov cloud + no-browser environments
# --cloud values: Public (default) · UsGov (GCC) · UsGovHigh (GCC High) · UsGovDod (DoD) · China PS> pac auth create --environment <url> --cloud UsGovHigh PS> pac auth create --environment <url> --deviceCode # jump boxes, Codespaces, headless VMs — auto-applied in GitHub Codespaces
02

Environment Lifecycle

There are two overlapping command groups here: the original pac admin (stable, simple) and the newer pac environment-management (Preview, far richer — DR, groups, provisioning templates, validate-only dry-runs). Use pac admin for routine day-to-day ops; reach for environment-management when you need DR, environment groups, or a dry-run before a destructive change.

Provision a new environment

Create + verify
PS> pac admin create --name "Contoso UAT" --type Sandbox --region unitedstates --currency USD --domain ContosoUAT # Or with the newer group — supports a validate-only dry-run before committing PS> pac environment-management provision-new-environment ` --display-name "Contoso UAT" --environment-sku Sandbox ` --location unitedstates --validate-only true # dry-run first, then rerun with false/omitted PS> pac admin list --json | ConvertFrom-Json | Where-Object DisplayName -eq "Contoso UAT"
pac admin create --input-file config.json takes the same properties as a JSON file — check a scaffolded environment definition into Git and provision the same shape every time instead of retyping flags.

Backup, restore, and copy

Point-in-time protection
# Manual backup before a risky change (in addition to the automatic nightly ones) PS> pac admin backup --environment <env-id> --label "Pre-migration snapshot" PS> pac admin list-backups --environment <env-id> # Restore the latest backup of Prod into UAT — refreshes UAT with real data PS> pac admin restore --selected-backup latest --source-env <prod-id> --target-env <uat-id> # Restore to a specific point in time instead PS> pac admin restore --selected-backup '12/01/2026 09:00' --source-env <prod-id> --target-env <uat-id> # Full-fidelity copy (schema + data) vs schema-only — name is required PS> pac admin copy --name "UAT Refresh" --source-env <prod-id> --target-env <uat-id> --type FullCopy
Set retention deliberately. pac admin set-backup-retention-period --environment <id> --backup-retention-period 21 — valid values are 7 / 14 / 21 / 28 days. Production environments used for compliance-sensitive workloads usually want 28; short-lived Dev environments don't need more than 7.

Disaster recovery (environment-management only)

Enable DR, drill it, fail over
PS> pac environment-management enable-disaster-recovery --environment <env-id> # Run a non-disruptive drill on a schedule — don't wait for a real outage to find out DR is broken PS> pac environment-management perform-dr-drill --environment <env-id> # Real failover to the paired region, and failing back once primary recovers PS> pac environment-management perform-force-failover --environment <env-id> PS> pac environment-management perform-failback --environment <env-id>

Environment groups & SKU changes

Group environments for group-level policy
PS> pac admin list-groups PS> pac admin add-group --environment <env-id> --environment-group <group-id> # Promote a Trial to a real SKU once a pilot proves out PS> pac environment-management modify-environment-sku --environment <env-id> --environment-sku Production

Decommission cleanly

Retire an environment
# Take a final backup, confirm nothing depends on it, then delete PS> pac admin backup --environment <env-id> --label "Final snapshot before decommission" PS> pac admin delete --environment <env-id> # Recovered a deletion by mistake? There's a recovery window. PS> pac environment-management recover-environment --environment <env-id>
Deletes are not instantly reversible past the recovery window. Always run pac admin backup immediately before pac admin delete, and confirm with the app/flow owners listed by pac power-apps get-admin-apps --environment <env-id> and pac power-automate list-cloud-flows --environment <env-id> that nothing live still points at it.
03

Users & Security Administration

Assign a user or group to an environment

Onboard a new team member
PS> pac admin assign-user ` --environment <env-id> --user "newhire@contoso.com" --role "Basic User" # Whole security group at once — far more scalable than per-user assignment PS> pac admin assign-group ` --environment <env-id> --group <entra-group-object-id> --group-name "Sales Team" ` --team-type AadSecurityGroup --membership-type Members --role "Salesperson" # Grant a service principal System Administrator — flag it explicitly as an app user PS> pac admin assign-user ` --environment <env-id> --user <app-id> --role "System Administrator" --application-user
Prefer groups over individual users. Assigning security roles to an Entra security group means offboarding is one Entra membership removal, not a per-environment cleanup hunt. It's also the only sane way to manage role assignment across dozens of environments.

Audit who has System Administrator everywhere

There's no single command for "who is admin in every environment" — you loop pac admin list against pac admin list-roles. This is exactly the kind of thing that's tedious by hand and trivial as a script (full version in Playbooks).

Quick single-environment check
PS> pac admin list-roles --environment <env-id> --include-child-roles

Self-elevate when you're locked out of an environment

Break-glass access
# Requires Global admin / Power Platform admin / Dynamics 365 admin at the tenant level PS> pac admin self-elevate --environment <env-id>
Self-elevate is an audited, visible action — it's the right tool for "I inherited this environment and nobody granted me access," not a routine habit. Remove the elevated role again once you've fixed what you needed to fix.

Application (Entra ID) registrations

Tenant-wide app inventory
PS> pac admin application list PS> pac admin application register --application-id <app-id> PS> pac admin application unregister --application-id <app-id> # Which Entra apps actually have Dataverse access, and where PS> pac admin list-service-principal --filter "Contoso"

RBAC role assignments — the newer, more granular model

pac authorization (Preview) manages role assignments scoped to a tenant, an environment, or an environment group — useful when you need finer-grained delegation than "System Administrator in this one environment."

pac authorization
PS> pac authorization list-role-definitions PS> pac authorization list-environment-role-assignments --environment <env-id> PS> pac authorization create-environment-group-role-assignment ` --environment-group-id <group-id> --principal-object-id <entra-object-id> --role-definition-id <role-id>

One-shot: apply System Administrator to a user, no environment context needed

pac user-management
PS> pac user-management apply-admin-role --environment <env-id>
04

DLP Policy & Managed Environment Governance

Inspect existing DLP policies

Audit before you change anything
PS> pac admin dlp-policy list PS> pac admin dlp-policy show --policy-name <policy-guid>
There's no pac admin dlp-policy create/update today — policy authoring is still a Power Platform admin center (or Power Platform API) operation. The CLI's role here is read/audit, not authoring. Script the audit; do the actual policy edit through the API or portal, then re-run dlp-policy list to confirm.

Turn on Managed Environments

Enable governance controls on a production environment
# Standard = Managed Environments on. Basic = off. Both required flags below. PS> pac admin set-governance-config ` --environment <env-id> --protection-level Standard ` --solution-checker-mode block --cloud-flows-mode Include --cloud-flows-limit 25
--solution-checker-mode block is the single highest-leverage flag here — it stops a solution import outright if Solution Checker finds high-severity issues, instead of just warning. Use warn while a team is ramping up, then tighten to block once their pipeline is clean.

Rule-based policies & cross-tenant reporting (newer, tenant-scale governance)

pac governance (Preview) operates one level up from a single environment's DLP policy — it assigns policies across environment groups and reports on cross-tenant connections, which matters once a tenant has dozens of environments and no single "click through each one" workflow is realistic.

pac governance
PS> pac governance list-rule-based-policies PS> pac governance list-rule-assignments --include-rule-set-counts true # Cross-tenant connections are a real data-exfiltration surface — check them regularly PS> pac governance create-cross-tenant-connection-report PS> pac governance list-cross-tenant-connection-reports

Solution Checker as a governance gate, not just a manual scan

Static analysis via pac solution check
PS> pac solution check --path .\MySolution.zip --geo UnitedStates --outputDirectory .\checker-results # --ruleLevelOverride points at a JSON file, not a bare level — e.g. downgrade one noisy rule instead of ignoring the whole run # overrides.json: [{"Id":"meta-remove-dup-reg","OverrideLevel":"Medium"}] PS> pac solution check --path .\MySolution.zip --geo UnitedStates --ruleLevelOverride .\overrides.json
Wire pac solution check into a build pipeline as a required gate, not just something an architect runs before a release. Combined with --solution-checker-mode block above, a low-quality solution literally cannot land in a Managed Environment.
05

Licensing, Capacity & Billing

The pac licensing group (Preview) is the CLI's biggest recent addition — 44 commands covering entitlements, capacity, and billing that used to require the admin center's Capacity page or a support ticket to even see clearly.

Capacity health at a glance

Tenant-wide capacity check
PS> pac licensing get-tenant-capacity-details PS> pac licensing list-storage-warnings PS> pac licensing get-many-environment-entitlements

Billing policies for pay-as-you-go

Link an environment to Azure billing
PS> pac licensing list-billing-policies PS> pac licensing get-billing-policy --billing-policy-id <policy-id> PS> pac licensing add-billing-policy-environment --billing-policy-id <policy-id> --environment-ids '["<env-id>"]'

Who's burning through capacity?

Consumption drill-down
# Find the noisiest users on a given entitlement (e.g. Dataverse storage, API requests) PS> pac licensing get-tenant-user-consumption-by-resource ` --entitlement-id <entitlement-id> --resource-id <resource-id> ` --from-date "2026-08-01" --to-date "2026-08-31"
This replaces a lot of guesswork. Before this command group existed, "which team is about to blow through our Power Automate per-flow capacity" was a support-ticket question. Now it's a scheduled script (see Playbook 4).
06

Solution ALM via CLI

This is where admin and pro-dev responsibilities overlap most — an admin promoting a solution between environments does the exact same commands a developer runs locally, just against Prod instead of a dev sandbox.

Export → Import promotion (the classic pattern)

Dev → Test → Prod
# Export as managed — the only form that should ever reach Prod PS> pac solution export ` --name ContosoCRM --path .\ContosoCRM_managed.zip --managed --environment <dev-id> # Run it through Solution Checker before it goes anywhere near Prod (see Governance section) PS> pac solution check --path .\ContosoCRM_managed.zip --geo UnitedStates # Import to Prod — publish-changes applies customizations immediately after import PS> pac solution import ` --path .\ContosoCRM_managed.zip --environment <prod-id> --publish-changes
--managed and --force-overwrite are switches (present/absent), not true/false values — --managed false silently does nothing useful; omit the flag entirely for an unmanaged export.

Inventory & versioning

What's actually deployed where
PS> pac solution list --environment <env-id> --json | ConvertFrom-Json # Confirm the version that landed matches what you expected to ship PS> pac solution online-version --solution-name ContosoCRM --environment <prod-id> # Bump version pre-release using git tags as the source of truth PS> pac solution version --strategy gittags

Pipeline-driven deployment

pac pipeline
# List pipelines, then drill into one for its deployment stage IDs PS> pac pipeline list --environment <env-id> PS> pac pipeline list --pipeline "ContosoCRM Release Pipeline" # Deploy — both version numbers and the stage ID are required PS> pac pipeline deploy ` --solutionName ContosoCRM --stageId <stage-id> ` --currentVersion 1.0.0.3 --newVersion 1.0.0.4 --wait
An admin's real ALM job is enforcement, not authorship. You're rarely the one running pac solution export day to day — you're the one making sure Managed Environments + Solution Checker + Pipelines are configured so a developer can't skip the gate, even by accident.

Cleanup — retire an obsolete solution

Delete safely
# Check dependencies before deleting — deleting a solution other components depend on breaks them PS> pac solution delete --solution-name LegacyIntegration --environment <env-id>
07

Tenant-Wide Monitoring & Auditing

Three newer command groups turn "someone should really check on this" into something you actually run on a schedule: advisor recommendations, a KQL query engine across the whole tenant, and read-only visibility into apps/flows/connections without needing to open each environment individually.

Power Platform advisor recommendations

pac analytics
PS> pac analytics get-recommendations PS> pac analytics get-recommendation-resources --scenario "UnusedApps" # Act on a recommendation directly from the CLI instead of clicking through the admin center card PS> pac analytics get-scenario-actions --scenario "UnusedApps" PS> pac analytics get-action-schema --scenario "UnusedApps" --action-name <action-name> PS> pac analytics execute-recommendation-action --scenario "UnusedApps" --action-name <action-name> --action-parameters '{"resourceIds":["<id>"]}'

Tenant-wide KQL — find anything, anywhere

pac resource-query
# Query resources across every environment via Azure Resource Graph — one call, whole tenant PS> pac resource-query query-resources --body '{"query":"PowerPlatformResources | where type == \"environment\" | project name, location"}' # Or keep the query in a file — much easier to iterate on and check into Git PS> pac resource-query query-resources --body @query.json
This is the tool for "find every X across the tenant" questions that used to require opening every environment one at a time — orphaned apps, flows owned by a departed employee, connections to a connector you're about to deprecate.

Read-only visibility without opening the maker portal

pac power-apps · pac power-automate · pac connectivity
PS> pac power-apps get-admin-apps --environment <env-id> PS> pac power-automate list-cloud-flows --environment <env-id> --owner-id <departed-user-guid> PS> pac connectivity list-connections --environment <env-id> PS> pac connectivity list-connectors --filter "<odata-filter>" # run --help for the exact filter syntax; --filter is required
These three groups are read-only inspection — they're the CLI equivalent of the admin center's "Apps"/"Flows"/"Connections" tabs, not a replacement for pac canvas/pac connection/pac connector when you need to actually act on something.
08

Automation Playbooks

Individual commands are useful; chained into a scheduled script, they replace a whole category of manual admin toil. These four are built entirely from commands verified earlier in this guide — copy, adapt the placeholders, and run.

🛡️ Playbook 1 — Weekly Environment Backup Audit Scheduled Task
Goal: catch an environment with no recent backup, or a retention setting that silently drifted, before you need a restore and discover it's not there.
weekly-backup-audit.ps1
# Run weekly via Task Scheduler / Azure Automation, mail or Teams-webhook the $stale list pac auth select --name "Prod-Audit" $envs = pac admin list --json | ConvertFrom-Json $stale = @() foreach ($e in $envs) { if ($e.EnvironmentType -ne "Production") { continue } $backups = pac admin list-backups --environment $e.EnvironmentId --json | ConvertFrom-Json $latest = $backups | Sort-Object PointDate -Descending | Select-Object -First 1 if (-not $latest -or ([datetime]$latest.PointDate) -lt (Get-Date).AddDays(-2)) { $stale += [PSCustomObject]@{ Name = $e.DisplayName; LastBackup = $latest.PointDate } } } $stale | Format-Table -AutoSize
👥 Playbook 2 — Tenant-Wide "Who Has System Administrator" Audit
Goal: a single report of every System Administrator across every environment — the question every security review eventually asks, answered in seconds instead of environment-by-environment clicking.
sysadmin-audit.ps1
$envs = pac admin list --json | ConvertFrom-Json $report = @() foreach ($e in $envs) { $principals = pac admin list-service-principal --json | ConvertFrom-Json # list-roles confirms the role exists in this env; cross-reference against your Entra PIM/group audit $roles = pac admin list-roles --environment $e.EnvironmentId --json | ConvertFrom-Json $sysadmin = $roles | Where-Object Name -eq "System Administrator" if ($sysadmin) { $report += [PSCustomObject]@{ Environment = $e.DisplayName; RoleId = $sysadmin.RoleId } } } $report | Export-Csv .\sysadmin-audit-$(Get-Date -Format yyyyMMdd).csv -NoTypeInformation
Pair this with pac admin list-service-principal specifically for app-registration accounts holding admin — those are the ones that don't show up in an Entra "list users with role X" query and are easiest to forget about.
💰 Playbook 3 — Capacity Early-Warning Report
Goal: know a storage or per-flow capacity ceiling is approaching two weeks out, not the day someone can't save a record.
capacity-warning.ps1
$warnings = pac licensing list-storage-warnings --json | ConvertFrom-Json $capacity = pac licensing get-tenant-capacity-details --json | ConvertFrom-Json if ($warnings.Count -gt 0) { Write-Host "⚠ $($warnings.Count) storage categories are near threshold" -ForegroundColor Yellow $warnings | Format-Table -AutoSize } # Drill into last month's consumption for the entitlement that's closest to its cap pac licensing get-tenant-license-trends ` --entitlement-id $capacity[0].EntitlementId ` --from-date (Get-Date).AddMonths(-1).ToString("yyyy-MM-dd") --to-date (Get-Date).ToString("yyyy-MM-dd")
🚫 Playbook 4 — Offboarding Sweep: Find Everything a Departed User Owned
Goal: when someone leaves, find every flow and app they owned across every environment before those resources silently stop working (a disabled account still "owns" a flow — it just fails at next run).
offboarding-sweep.ps1
$departedUserId = "<entra-object-id>" $envs = pac admin list --json | ConvertFrom-Json $owned = @() foreach ($e in $envs) { $flows = pac power-automate list-cloud-flows --environment $e.EnvironmentId --owner-id $departedUserId --json | ConvertFrom-Json foreach ($f in $flows) { $owned += [PSCustomObject]@{ Environment = $e.DisplayName; Type = "Flow"; Name = $f.Name } } } $owned | Format-Table -AutoSize # Reassign ownership via the maker portal, or script it with pac power-automate + connection-owner transfer where supported
This finds flows owned by a specific person, not apps — pac power-apps get-admin-apps doesn't currently support filtering by owner, so cross-reference its full list against the departed user's ID manually or pipe through Where-Object once you have the objects.
09

Gotchas & Troubleshooting

Symptom / QuestionWhat's actually going on
Script output is unparseable / truncatedYou forgot --json. Almost every read command in this guide supports it — the human-readable table format is not meant to be piped into ConvertFrom-Json.
"Which group do I use — pac admin or pac environment-management?"They overlap on purpose. pac admin is the stable, long-standing group; pac environment-management (Preview) is newer and has DR, groups, and validate-only dry-runs that pac admin doesn't. Both are actively maintained — use whichever has the capability you need.
A destructive command "succeeded" instantly with no confirmationThe CLI doesn't prompt for confirmation on delete/restore/reset. That's the entire point of scripting it — but it also means a typo'd environment ID is unrecoverable in seconds. Always echo the target back and pause before anything destructive in a script (see the Playbooks' pattern of printing before acting).
A long-running operation seems to hangEnvironment create/copy/restore/reset are asynchronous server-side. Add --max-async-wait-time <minutes> (default 60) if the default isn't enough, or --async to fire-and-forget and poll pac admin status separately.
"Can I author a DLP policy from the CLI?"Not yet — pac admin dlp-policy is read-only (list/show). Authoring still goes through the admin center or the Power Platform API directly. Script the audit trail, not the edit.
Environment identifier keeps changing format in examplesMost commands accept a GUID or a URL or a unique/partial name interchangeably for --environment. Pick one convention for your scripts (GUID is safest — names can collide) and stick to it.
A Preview command group disappeared or renamed a flagEverything marked Preview in this guide (environment-management, governance, licensing, analytics, authorization, connectivity, power-apps, power-automate, resource-query, user-management, app-management, dynamics, copilot-studio, workflows-agent, power-pages) can change shape before GA. Run pac install latest monthly and re-check --help if a scheduled script starts failing.
Service principal script fails with a permissions errorEnvironment-level permissions alone aren't always enough — some commands need a specific security role, not just System Administrator at the tenant level. Check the exact role a failing command needs before assuming the SPN itself is broken.
Tenant-wide query (pac resource-query, pac admin query) times out or returns partial dataKQL/Resource Graph queries at tenant scale can be slow on large tenants. Narrow the query's where clause before assuming the command is broken — a query with no filter at all against thousands of environments is going to be slow anywhere.