In this blog post, we’ll walk you through the process of exporting a list of all Power Platform environments using PowerShell.
Managing Power Platform environments can be challenging, especially when dealing with a large number of environments. Exporting a list of all environments to a CSV file can make it easier to review and analyze your organization’s environments.
Install-Module and Login
Before starting, ensure that you have the following:
PowerShell 5.1 or later installed on your computer.
The Power Platform PowerShell modules are installed. You can install them by running the following commands in PowerShell:
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber
Authenticate to your Power Platform environment by running the following command:
Add-PowerAppsAccount
Export
Run the following script to get a list of all environments and export them to a CSV file:
$environments = Get-AdminPowerAppEnvironment
$environments | Select-Object EnvironmentName, DisplayName, CreatedBy, CreatedTime, LastModifiedBy, LastModifiedTime | Export-Csv -Path "Environments.csv" -NoTypeInformation
This script retrieves a list of environments using the Get-AdminPowerAppEnvironment
cmdlet and selects specific properties, such as the environment name, display name, creator, and modification details. The Export-Csv
cmdlet exports the selected data to a CSV file named “Environments.csv” in the current working directory.