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.
Install-Module Microsoft.Graph -Scope CurrentUser -Force
Import-Module Microsoft.Graph.Users
Import-Module Microsoft.Graph.Reports
Connect-MgGraph -Scopes "User.Read.All", "AuditLog.Read.All", "Reports.Read.All"
$powerBISkuId = "f8cdef31-a31e-4b4a-93e4-5f571e91255a"
$licensedUsers = Get-MgUser -All | Where-Object {
$_.AssignedLicenses.SkuId -contains $powerBISkuId
}
$report = @()
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"
}
}
}
$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!