web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to get a list of u...
Power Automate
Unanswered

How to get a list of users with Power BI license and their last activity date

(0) ShareShare
ReportReport
Posted on by

Hello, I'm trying to generate a simple report that shows:

  • Which users in my tenant have an active Power BI license
  • When was their last activity on Power BI (e.g., report view)

I’ve already checked the Microsoft 365 Admin Center, under Reports > Usage, but there is no entry related to Power BI that allows me to see the last activity per user.

I also tried using PowerShell, following various documentation online and using the script below, but it does not work properly.

PowerShell
 
# Install and import Microsoft Graph module
Install-Module Microsoft.Graph -Scope CurrentUser -Force
Import-Module Microsoft.Graph.Users
Import-Module Microsoft.Graph.Reports

# Authenticate with required permissions
Connect-MgGraph -Scopes "User.Read.All", "AuditLog.Read.All", "Reports.Read.All"

# Power BI Pro license SKU GUID
$powerBISkuId = "f8cdef31-a31e-4b4a-93e4-5f571e91255a"

# Get all users with Power BI Pro license
$licensedUsers = Get-MgUser -All | Where-Object {
    $_.AssignedLicenses.SkuId -contains $powerBISkuId
}

# Initialize report list
$report = @()

# Retrieve recent activity from Microsoft 365 Audit Log (Power BI)
foreach ($user in $licensedUsers) {
    $email = $user.UserPrincipalName

    try {
        $activity = Search-UnifiedAuditLog -StartDate (Get-Date).AddDays(-30) `
                                           -EndDate (Get-Date) `
                                           -UserIds $email `
                                           -RecordType PowerBI `
                                           -Operations "ViewReport" `
                                           -ResultSize 1 |
                    Sort-Object CreationDate -Descending |
                    Select-Object -First 1

        $lastUsed = if ($activity) { $activity.CreationDate } else { "Not used in the last 30 days" }

        $report += [PSCustomObject]@{
            UserPrincipalName = $email
            LastActivity = $lastUsed
        }
    } catch {
        $report += [PSCustomObject]@{
            UserPrincipalName = $email
            LastActivity = "Error retrieving activity"
        }
    }
}

# Export to CSV
$downloadPath = [System.IO.Path]::Combine($env:USERPROFILE, "Downloads", "PowerBI_Users_License_LastActivity.csv")
$report | Export-Csv -Path $downloadPath -NoTypeInformation -Encoding UTF8
Write-Host "✅ File exported: $downloadPath"

Is there an official, supported, and working method to get a list of users with Power BI licenses and their last activity (e.g., report view, login, etc.)?

I just need a simple report, preferably exportable, to identify users who have a license but are not using Power BI.

Thanks in advance!

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at
     
    Where did you find this script? Or is it generated by for example ChatGPT?
     
    The reason the script is not working is because the Search-UnifiedAuditLog cmdlet is not part of the Microsoft.Graph module but it is part of the Exchange Online module. 
     
    Find-MgGraphCommand -Command "Search-UnifiedAuditLog"


    Have you tried including the Exchange Online PowerShell module in your script as well?
    https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/search-unifiedauditlog?view=exchange-ps


     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • lbendlin Profile Picture
    8,649 Super User 2026 Season 1 on at
    There is no need for this. Power BI Pro licenses are managed via a distribution list.  Find out which list your company is using, then enumerate that list.
     
    Please define what you mean by "last activity" - last activity that required a Pro license?
  • Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at
     
    In the opening post @FR-16090658-0 mentioned a definition for the last activity, just below the script 👍
    Is there an official, supported, and working method to get a list of users with Power BI licenses and their last activity (e.g., report view, login, etc.)?

    And from the comment below in the PowerShell script it looks like FR-16090658-0 wants to use the M365/Purview Audit Logs for tracking/checking these activities.
    # Retrieve recent activity from Microsoft 365 Audit Log (Power BI)
     
     



     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard