5 Useful PowerShell scripts for PowerApps & Power Automate Reporting

Hello all, today we will see 5 Useful PowerShell scripts for PowerApps & Power Automate Reporting. As we all know that still in this world of user friendly GUI, we admin need scripting. And powershell is one of the most powerful tool used in Microsoft ecosystem.

How to install and connect with Power Platform ?

Before proceeding towards Handy PowerShell scripts for PowerApps & Power Automate reporting , we must know “How to install and connect with Power Platform ?”.

  1. Launch windows powershell as an admin as shown in Figure 1.
Launch PS
Figure 1

2. Run the below commads.

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

Type A, accept all the installation policies and then connect to your environment. Use below command for the same.

# Here is how you can pass in credentials (avoiding opening a prompt)
$pass = ConvertTo-SecureString "password" -AsPlainText -Force
Add-PowerAppsAccount -Username [email protected] -Password $pass

You can refer this link for more details.

Useful scripts for reporting.

1. Script to export all the Flows.

Get-AdminFlow | Export-Csv -Path 'E:\Powershell OutPut\FlowExport.csv'
Import-CSV "E:\Powershell OutPut\FlowExport.csv" | ConvertTo-Html | Out-File "E:\Powershell OutPut\Report.html"

In this same script we can add condition for Enabled flows.

Get-AdminFlow |  Where {$_.Enabled -like "True" } | Export-Csv -Path 'E:\Powershell OutPut\FlowExport.csv'
Import-CSV "E:\Powershell OutPut\FlowExport.csv" | ConvertTo-Html | Out-File "E:\Powershell OutPut\Report.html"

2. Display the number of apps in each environment

Get-AdminPowerApp | Select -ExpandProperty EnvironmentName | Group | %{ New-Object -TypeName PSObject -Property @{ DisplayName = (Get-AdminPowerAppEnvironment -EnvironmentName $_.Name | Select -ExpandProperty displayName); Count = $_.Count } } | Export-Csv -Path 'E:\Powershell OutPut\appdetails.csv'
Script Example
Figure 2

3. Set, Find Hero app and also set feature application

Get-AdminPowerApp | where{$_.IsHeroApp -eq "True"} -- Find Hero App
Get-AdminPowerApp 'App Display Name' | Set-AdminPowerAppAsHero -- Set a hero app
Set-AdminPowerAppAsFeatured –AppName '<APP Name which is GUID>'
-- set a feature app
Is Hero App
Figure 3.

4. Export PowerApp Connection Role Assignment

Get-AdminPowerAppConnectionRoleAssignment | select -Property PrincipalDisplayName, RoleType,ConnectionName,ConnectorName | Export-Csv -Path 'E:\Powershell OutPut\ConnectionRoleAssignment.csv'
Import-CSV "E:\Powershell OutPut\ConnectionRoleAssignment.csv" | ConvertTo-Html | Out-File "E:\Powershell OutPut\ConnectionRoleAssignment.html"
PowerApps & Power Automate Reporting
Figure 4.

5. Export all the run of a specific flow in your tenant into a tabular view .csv file and also creates a HTML file. In below script user can input there desired flow name.

$flowname = Read-Host "Please enter desired flow name"
Get-FlowRun -FlowName $flowname | select -Property Status, StartTime | Export-Csv -Path 'E:\Powershell OutPut\Flowstatus.csv'
Import-CSV "E:\Powershell OutPut\Flowstatus.csv" | ConvertTo-Html | Out-File "E:\Powershell OutPut\Flowstatus.html"
PowerApps & Power Automate Reporting
Figure 5.
PowerApps & Power Automate Reporting
Figure 6.

Hope you all will like this article. Please share and subscribe our page for more articles. You can see our articles here. Please drop us an email at [email protected] for any queries.