5 useful PowerShell scripts for PowerApps & Power Automate Reporting


Posted By : Rakesh Pandey

Added :

10 Comments


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.

0 0 votes
Article Rating
Subscribe
Notify of
guest
10 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
David Stone
1 year ago

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)

Naresh
Naresh
1 year ago

Is it possible to have a loop to get the run history of all active flows with a single script?

lumi
lumi
8 months ago
Reply to  Rakesh Pandey

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

Nidi
Nidi
1 year ago

how to use PowerShell Scripts in Power Automate Desktop ?

Skhare
Skhare
10 months ago

is there a way to add users as maker to a sandbox environment through powershell script

Texas Systems
Texas Systems
9 months ago

Amazing article! how to use PowerShell Scripts in Power Automate mobile?