This script exports every unmanaged solution in a Dataverse environment and unzips each into its own folder. Commit them for a baseline; every later run shows what changed. Handy when you inherit an environment someone else built: the maker portal only exports one at a time.
What it does
- Runs
pac solution listagainst your active auth profile and saves it tosolutions-list.txt. - Warns if line five doesn’t start with
Unique Name: wrong environment, or the CLI output changed. - Skips managed solutions and Default, which can’t be exported.
- Exports the rest with
pac solution export --name(unmanaged by default). - Unzips each into a folder named after the solution and deletes the zip.
$skipExisting = $true at the top keeps folders you already have and only fetches new solutions. The default re-exports everything.
Before you run it
- Install the Power Platform CLI.
pac auth create, thenpac env select. Checkpac env who: it runs against whatever’s active.- Run it in an empty folder, or one holding only earlier backups. It treats every subfolder as a solution.
The repo version
dataverse-solution-scanner does the same with more:
- Multiple environments from
config/environments.json, checked against a schema, intosolutions/<name>/. - Keeps each zip under
_backups, ready forpac solution import. - Unzips canvas apps (
.msapp) too, so they diff. - Needs PowerShell 7.
Its security-scan.ps1 runs regex rules over the exports. It’s a demo, and the README says not to rely on it; use TruffleHog or Kingfisher.
What it misses
- Unpublished changes. Exports only include published components.
pac solution publishfixes that, but publishes everyone’s work in progress. - Anything only in Default.
- Data. Solutions carry customisations, not records.
- Tidy diffs. It uses
Expand-Archive.pac solution unpackgives a file per component, which Microsoft prefers. For canvas apps only the*.pa.yamlunderSrcbelong in source control. - A sturdy parser. It counts lines in a table meant for people.
--jsonwould be better. - Secret scrubbing. Exports can hold keys. Check before committing anywhere shared, or pasting into an AI tool.
For a development Managed Environment, Dataverse Git integration is the built-in way to keep solutions in an Azure DevOps Git repo, in a YAML format that diffs far better. Microsoft says dev only, not test or production. The script still works when you just want a copy of what’s there.