Power Platform performance monitoring helps in identifying slow apps, inefficient flows, and resource bottlenecks. Automating this process using PowerShell ensures proactive detection and resolution of performance issues.
Step 1: Prerequisites
1.1 Install Required PowerShell Modules
Ensure the required modules are installed:
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force
Install-Module -Name Microsoft.PowerApps.PowerShell -Force
1.2 Authenticate to Power Platform
Add-PowerAppsAccount
Step 2: Monitoring Performance Metrics
2.1 Retrieve Power Apps Performance Data
Get a list of Power Apps and their performance metrics:
Get-AdminPowerApp | Select-Object DisplayName, AppId, EnvironmentName, CreatedTime
Check slow-running apps (apps taking longer than 2 seconds to load):
Get-AdminPowerAppPerformance -EnvironmentName "your-env-id" | Where-Object { $_.AvgLoadTime -gt 2 } |
Select-Object AppName, AvgLoadTime, UserCount
2.2 Retrieve Flow Performance Data
Identify flows with high execution times:
Get-AdminFlowRun -EnvironmentName "your-env-id" | Where-Object { $_.Duration -gt 5000 } |
Select-Object FlowName, Status, Duration, StartTime
(Duration is in milliseconds)
2.3 Check Dataverse Query Performance
Identify slow Dataverse queries:
Get-CrmEntityPerformance -EnvironmentName "your-env-id" |
Where-Object { $_.AverageResponseTime -gt 500 } |
Select-Object EntityName, AverageResponseTime, RequestCount
(Average response time is in milliseconds)
Step 3: Automating Performance Monitoring
3.1 Create a Scheduled PowerShell Script
Save the following script as Monitor-PowerPlatform.ps1:
$envName = "your-env-id"
# Authenticate
Add-PowerAppsAccount
# Retrieve slow Power Apps
$slowApps = Get-AdminPowerAppPerformance -EnvironmentName $envName | Where-Object { $_.AvgLoadTime -gt 2 }
$slowApps | Export-Csv -Path "C:\Logs\SlowApps.csv" -NoTypeInformation
# Retrieve slow Power Automate Flows
$slowFlows = Get-AdminFlowRun -EnvironmentName $envName | Where-Object { $_.Duration -gt 5000 }
$slowFlows | Export-Csv -Path "C:\Logs\SlowFlows.csv" -NoTypeInformation
# Retrieve slow Dataverse queries
$slowQueries = Get-CrmEntityPerformance -EnvironmentName $envName | Where-Object { $_.AverageResponseTime -gt 500 }
$slowQueries | Export-Csv -Path "C:\Logs\SlowQueries.csv" -NoTypeInformation
Write-Host "Performance data exported to C:\Logs\"
3.2 Schedule the Script to Run Daily
To automate execution, create a Windows Task Scheduler job:
- Open Task Scheduler
- Click Create Basic Task
- Set a Trigger (Daily at 12 AM)
- Set Action → Start a Program
- Browse for powershell.exe
- Add arguments:
-File "C:\Scripts\Monitor-PowerPlatform.ps1"
- Click Finish
This ensures the script runs daily and exports performance logs automatically.
Step 4: Sending Performance Reports via Email
Modify the script to send reports via email:
$SMTPServer = "smtp.office365.com"
$SMTPPort = "587"
$EmailFrom = "your-email@domain.com"
$EmailTo = "admin@domain.com"
$Subject = "Power Platform Performance Report"
$Body = "Attached are the latest Power Platform performance logs."
$Username = "your-email@domain.com"
$Password = "your-email-password"
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($Username, $securePassword)
$attachments = @("C:\Logs\SlowApps.csv", "C:\Logs\SlowFlows.csv", "C:\Logs\SlowQueries.csv")
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Port $SMTPPort -Credential $cred -UseSsl -Attachments $attachments
This sends performance logs to administrators automatically.
Step 5: Analyzing Logs with Power BI
To visualize performance trends, load CSV logs into Power BI:
- Open Power BI Desktop
- Click Get Data → CSV
- Load SlowApps.csv, SlowFlows.csv, SlowQueries.csv
- Create charts for trends in:
- App load times
- Flow execution duration
- Dataverse response times
Power BI helps track performance over time and identify recurring issues.