how to get the last use date of power apps via powershell script

Esha Adhya 0 Reputation points
2026-11-18T14:40:33.4766667+00:00

how to get the last use date of power apps via powershell script

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

2 answers

Sort by: Oldest
  1. AI answer

    2026-11-18T14:41:41.4966667+00:00

    Use Power Apps “Launched app” audit events and select the newest event for each app; Get-AdminPowerApp returns app information but does not provide a documented last-used property.^1^

    PowerShell script

    The following script searches the Unified Audit Log, identifies Power Apps launch events from PropertyCollection, groups them by app ID, and exports the latest launch date.

    Connect-ExchangeOnline
    
    $start = (Get-Date).AddDays(-90).ToUniversalTime()
    $end = (Get-Date).ToUniversalTime()
    $session = "PowerApps-$([guid]::NewGuid())"
    $events = @()
    
    do {
        $page = @(Search-UnifiedAuditLog -StartDate $start -EndDate $end `
            -SessionId $session -SessionCommand ReturnLargeSet)
        $events += $page
    } while ($page.Count -gt 0)
    
    $report = foreach ($event in $events) {
        $data = $event.AuditData | ConvertFrom-Json
        $props = @{}
        foreach ($item in $data.PropertyCollection) { $props[$item.Name] = $item.Value }
    
        if ($props['powerplatform.analytics.resource.type'] -eq 'PowerApp' -and
            $props['powerplatform.analytics.activity.name'] -match 'Launch') {
            [pscustomobject]@{
                AppId       = $props['powerplatform.analytics.resource.power_app.id']
                AppName     = $props['powerplatform.analytics.resource.power_app.display_name']
                Environment = $props['powerplatform.analytics.resource.environment.name']
                LastUsedUTC = [datetime]$event.CreationDate
            }
        }
    }
    
    $report | Group-Object AppId | ForEach-Object {
        $_.Group | Sort-Object LastUsedUTC -Descending | Select-Object -First 1
    } | Sort-Object LastUsedUTC -Descending |
        Export-Csv ".\PowerApps-LastUsed.csv" -NoTypeInformation
    

    Power Apps records identify an app through fields such as:

    • powerplatform.analytics.resource.type = PowerApp
    • powerplatform.analytics.resource.power_app.id
    • powerplatform.analytics.resource.power_app.display_name
    • powerplatform.analytics.resource.environment.name
    • powerplatform.analytics.activity.name

    The recorded activity time is exposed as the audit event’s CreationDate. Power Apps auditing explicitly includes Launched app events.^2^ Audit payload details are JSON, so the script must parse AuditData and its workload-specific properties.^3^

    Prerequisites

    • Assign the account either the Audit Logs or View-Only Audit Logs role in Microsoft Purview.
    • Ensure auditing is configured for the Power Platform production environments being monitored.^2^
    • Install the Exchange Online PowerShell module if necessary, then authenticate with Connect-ExchangeOnline.
    • Change AddDays(-90) to the required reporting window. Results are limited to events still retained in the audit log, so “last used” means the last launch within the searchable retention period.

    Large tenants and missing results

    Search-UnifiedAuditLog returns only 100 records by default. Reusing the same SessionId with ReturnLargeSet, as the script does, retrieves pages up to the documented 50,000-result limit; those pages are unsorted.^4^

    If the search reaches 50,000 records, divide the reporting period into smaller ranges—such as weekly or daily windows—and combine the results before grouping. Microsoft specifically recommends reducing the date range when the 50,000-record limit is reached.^5^

    If the CSV is empty, first run a launch-event search in Microsoft Purview → Solutions → Audit, open one result, and inspect its powerplatform.analytics.activity.name value. Replace the script’s -match 'Launch' test with that exact value if needed.

    Apps with no launch event in the selected or retained period cannot be assigned an exact last-used date; report those as No launch found in audit period, rather than assuming they were never used.


    References

    1. Get-AdminPowerApp-Description
    2. View Power Apps activity logs in Microsoft Purview
    3. Best Practices using the Search-UnifiedAuditLog cmdlet tool
    4. Search-UnifiedAuditLog-Description
    5. Use a PowerShell script to search the audit log
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

  2. Harry Phan 36,850 Reputation points Independent Advisor
    2026-11-18T15:12:17.6366667+00:00

    Hello Esha,

    The Get-AdminPowerApp cmdlet can retrieve app details, but it does not directly provide a reliable last-used date.

    To identify the last launch date, use the Microsoft Purview audit logs through Exchange Online PowerShell. First, connect using Connect-ExchangeOnline, then search for Power Apps launch activities:

    $StartDate = (Get-Date).AddDays(-90)
    $EndDate = Get-Date
    
    $Logs = Search-UnifiedAuditLog `
        -StartDate $StartDate `
        -EndDate $EndDate `
        -FreeText "AppName" `
        -ResultSize 5000
    
    $Logs | ForEach-Object {
        $Audit = $_.AuditData | ConvertFrom-Json
        [PSCustomObject]@{
            Date       = $_.CreationDate
            Operation  = $_.Operations
            User       = $_.UserIds
            AuditData  = $_.AuditData
        }
    } | Format-Table -AutoSize
    

    Filter the results for the Launched app activity and the relevant application ID to identify its most recent usage date. Note that audit logging must be enabled and your account needs the appropriate audit permissions. The available history also depends on your Microsoft 365 audit retention period.

    For tenant-wide app inventory, you can combine this with Get-AdminPowerApp.

    Best regards,

    Harry P.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.