Power Platform Tidbits 8: Download the full metadata of your Dataverse environment by one PowerShell command

You can always visit get the full metadata of a Power Platform environment (or Dynamics 365) from https://{your-environment}.{region-specific-url}/api/data/v9.2/$metadata. For example if your environment is hosted in Europe, the URL can be:


But sometimes the data can be too much for your browser to digest, specially if you have a plugin that formats or beautifies XML content. In that case you can always use PowerShell or more precisely PSDataverse to download and save the metadata as an XML file. It just takes two lines in Powershell, and the first line is to connect.

Connect-Dataverse "authority=https://login.microsoftonline.com/{tenant-id}/oauth2/authorize;clientid=1950a258-227b-4e31-a9cf-717495945fc2;resource=https://mytestenvironment.crm4.dynamics.com/;device=true"
Send-DataverseOperation "`$metadata" | Select-Object -ExpandProperty Content | Set-Content ".\schema.xml"

A screenshot of Windows Terminal. The screenshot shows two commands and their result. The first command is "Connect-Dataverse" with a connection string that uses device flow to authenticate. The second command is "Send-DataverseOperation "`$metadata" | Select-Object -ExpandProperty Content | Set-Content -Path ".\schema.xml".
Both commands are executed successfully.
In my case, it took 8 seconds to download and save the file from a trial environment.

If you are not familiar with PSDataverse, just know that it takes only one line to install it. Read more in the official Github repository

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.