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 ?”.
- Launch windows powershell as an admin as shown in 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'

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

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"

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"


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.
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)
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.
Is it possible to have a loop to get the run history of all active flows with a single script?
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.
Hi
Can you turn on/turn off multiple flows from power shell ?
below seems to start a flow, only looking to turn on not to actual start it
Enable-AdminFlow -EnvironmentName $YourEnvironmentId -FlowName $YourFlowId
thank you
how to use PowerShell Scripts in Power Automate Desktop ?
Very soon we are going to publish a video on our youtube channel on how to use PowerShell action in Power Automate Desktop. Subscribe to our channel for more updates.
Channel link: https://www.youtube.com/c/flexmind
https://www.youtube.com/watch?v=-LZRHLziotY
is there a way to add users as maker to a sandbox environment through powershell script
Amazing article! how to use PowerShell Scripts in Power Automate mobile?
You’d need to call an Azure Runbook or Function App from a Flow to trigger a script.