Shantha Kumar T
Export the list of all powerapps from all environments across Microsoft 365 Tenant
In the fast-paced world of data management and automation, the ability to export data efficiently is a skill highly required by professionals across various fields. Fortunately, PowerShell scripts offer a powerful solution to streamline this process, allowing users to extract and manipulate data with ease.
Here’s a simple PowerShell script that assists in exporting the list of all PowerApps applications across all environments from PowerPlatform within Microsoft 365 Tenant by utilising PnP PowerShell.
PnP PowerShell version used:2.4.63-nightly
#Export all powerapps available in each environment in Microsoft 365 $siteurl = "https://<tenant>-admin.sharepoint.com" Connect-PnPOnline $siteurl -Interactive Write-Host "Execution Started..." $environments = Get-PnPPowerPlatformEnvironment Write-Output "Total environments: "$environments.length If ($environments.length -gt 0) { $results = @() foreach ($env in $environments) { $powerapps = Get-PnPPowerApp -Environment $env.Name -AsAdmin If($powerapps.length -gt 0){ Write-Host $env.Properties.DisplayName " - " $powerapps.length " apps found." foreach($app in $powerapps){ Write-Host $app $results += [pscustomobject][ordered]@{ EnvironmentID = $env.Name Environment = $env.Properties.DisplayName ID = $app.Name DisplayName = $app.properties.DisplayName Created = $app.properties.CreatedTime Modified = $app.properties.LastModifiedTime CreatedBy = $app.properties.CreatedBy.DisplayName ModifiedBy = $app.properties.LastModifiedBy.DisplayName PlayUrl = $app.properties.AppPlayUri AppVersion = $app.properties.AppVersion AppLocation = $app.Location AppType = $app.AppType } } }else{ $results += [pscustomobject][ordered]@{ EnvironmentID = $env.Name Environment = $env.Properties.DisplayName ID = "" DisplayName = "" Created = "" Modified = "" CreatedBy = "" ModifiedBy = "" PlayUrl = "" AppVersion = "" AppLocation = "" AppType = "" } Write-Host $env.Properties.DisplayName " - No apps available!" } } $results | Export-Csv -Path "allenvironmentpowerapps.csv" -NoTypeInformation Write-Host "Export Completed." } Write-Host "Execution Completed."
The above script executes and iterates all the environments in a Microsoft 365 Tenant and fetches all the powerapps applications. Then it exports in to the csv file in current running path.
Note: The user who runs the script, should have access to all the environments. Other wise it returns an error says.