Exporting Power Apps Information to a CSV using PowerShell

Loading

Exporting Power Apps information to a CSV file using PowerShell helps administrators track applications, audit environments, and maintain documentation. This process allows for easy analysis and reporting of all Power Apps within a Power Platform environment.


Step 1: Install Required PowerShell Modules

Ensure you have the necessary PowerShell modules installed:

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force -AllowClobber
Install-Module -Name Microsoft.PowerApps.PowerShell -Force -AllowClobber

If prompted, press Y to confirm the installation.


Step 2: Authenticate to Power Platform

Connect to Power Platform using an Admin account:

Add-PowerAppsAccount

A Microsoft sign-in window will appear. Log in using your Global Admin or Power Platform Admin credentials.

For service principal authentication (without manual login), use:

$clientId = "your-client-id"
$clientSecret = "your-client-secret"
$tenantId = "your-tenant-id"

$SecureSecret = ConvertTo-SecureString $clientSecret -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($clientId, $SecureSecret)

Connect-AdminPowerAppEnvironment -TenantId $tenantId -Credential $Credential

Step 3: Retrieve Power Platform Environments

To list all available environments:

Get-AdminPowerAppEnvironment | Select-Object DisplayName, EnvironmentName, Location, EnvironmentSku

Identify the EnvironmentName where you want to export Power Apps information.


Step 4: List All Power Apps in an Environment

Retrieve all Power Apps from a specific environment:

$environmentId = "your-environment-id"

Get-AdminPowerApp -EnvironmentName $environmentId | Select-Object DisplayName, AppName, CreatedTime, LastModifiedTime

This command displays:

  • DisplayName – The user-friendly name of the app
  • AppName – The unique identifier for the app
  • CreatedTime – The date the app was created
  • LastModifiedTime – The last modification date

Step 5: Export Power Apps Data to a CSV File

To save the Power Apps details in a CSV file for documentation and analysis:

$exportPath = "C:\PowerPlatform\PowerAppsList.csv"

Get-AdminPowerApp -EnvironmentName $environmentId |
Select-Object DisplayName, AppName, CreatedTime, LastModifiedTime |
Export-Csv -Path $exportPath -NoTypeInformation

Step 6: Verify Exported Data

Navigate to C:\PowerPlatform and open PowerAppsList.csv in Excel to verify that the information has been successfully exported.


Step 7: Disconnect from Power Platform

Once done, disconnect the session:

Disconnect-PowerAppsAccount

Leave a Reply

Your email address will not be published. Required fields are marked *