5 useful PowerShell scripts for PowerApps & Power Automate Reporting

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 test@test.com -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 learning@flexmind.co for any queries.

Sharing is Caring

7 thoughts on “5 useful PowerShell scripts for PowerApps & Power Automate Reporting”

  1. Hi Ya, I love what you wrote up. Is there any way to take it one step further and trigger a powershell script?

    (Exchange logs keep filling up randomly, and I would a nice tidy tracking and remediation process all in one)

    1. Hi David,

      Correct me, if my understanding is not aligned with your query. Do you want to trigger the PS script using other tools or interfaces? If yes, there are many ways. 1) You can schedule the script using windows scheduler to run daily and extract the report. 2) You can also use Power Automate Desktop to do the same also.
      Let us know whether we are able to answer your query or not.
      Thanks.

    1. Not with a single script, but you can use the below step.
      1) Get-AdminFlow | Where {$_.Enabled -like “True” }, use this to get all active flows.
      2) Now loop in this collection of active flows and use Get-FlowRun -FlowName $flowname to get the run history of each flows.
      3) Export the result in a CSV file.

Leave a Comment

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

Scroll to Top