Monitoring user activity in Power Platform helps administrators track usage patterns, detect anomalies, and enforce governance policies. This guide explains how to use PowerShell to monitor user activity, retrieve logs, and automate reporting.
What You’ll Learn:
Connecting to Power Platform
Retrieving user activity logs
Filtering logs for specific users or events
Exporting activity data to CSV
Automating user activity monitoring
Step 1: Prerequisites
1. Install Required PowerShell Modules
Ensure you have the necessary PowerShell modules installed:
Install-Module -Name ExchangeOnlineManagement -Force
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force
Install-Module -Name Microsoft.PowerPlatform.Cds.Client -Force
2. Connect to Power Platform and Exchange Online
Power Platform activity logs are stored in Microsoft 365 Unified Audit Logs. Connect using:
Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com
Add-PowerAppsAccount
Now you are connected to Power Platform and can retrieve logs.
Step 2: Retrieve Power Platform User Activity Logs
To fetch user activity logs from Microsoft 365 Audit Logs:
Search-UnifiedAuditLog -StartDate (Get-Date).AddDays(-7) -EndDate (Get-Date) `
-RecordType PowerAppsApp -ResultSize 1000 |
Select-Object CreationDate, UserIds, Operations, AuditData |
Export-Csv -Path "C:\PowerPlatform_UserActivity.csv" -NoTypeInformation
Write-Output "User activity logs exported to C:\PowerPlatform_UserActivity.csv"
This retrieves the last 7 days of PowerApps activity logs.
Step 3: Filter Logs for Specific Users or Events
To find activities related to a specific user:
$UserEmail = "user@example.com"
Search-UnifiedAuditLog -StartDate (Get-Date).AddDays(-7) -EndDate (Get-Date) `
-RecordType PowerAppsApp -ResultSize 1000 |
Where-Object { $_.UserIds -match $UserEmail } |
Select-Object CreationDate, UserIds, Operations, AuditData |
Export-Csv -Path "C:\UserActivity_$UserEmail.csv" -NoTypeInformation
Write-Output "User-specific activity logs exported to C:\UserActivity_$UserEmail.csv"
This exports logs for a specific user.
Step 4: Automate User Activity Monitoring
To schedule this as a weekly task:
- Open Task Scheduler
- Click Create Basic Task
- Set weekly recurrence
- Choose Start a Program → PowerShell.exe
- Add script path:
-File "C:\Scripts\Monitor_PowerPlatform_Activity.ps1"
- Click Finish
Now, PowerShell will automatically monitor and export user activity logs.