Forum Discussion
Track Power BI user activities with Activity Log
We have a necessity to track user access to specific reports on our Power BI instance. According to the this article, we can use the activity log to retrieve tracking/audit information for a Power BI instance.
Track user activities in Power BI - Power BI | Microsoft Learn
In the process of researching and learning, I have been trying REST APIs with Powershell. I have been able to call straightforward REST APIs such as the ones that return all of the datasets. I have been using an account that is a Power BI Administrator and I have installed all of the required Power BI Cmdlets in Powershell.
However, I have not had any success with calling the API to retrieve tracking information. For a simple test the article shows this command:
I have tried calling it in Powershell using this command:
Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='2023-02-10T00:00:00'&endDateTime='2023-02-12T23:59:59'' -Method Get
It fails with this message:
Invoke-PowerBIRestMethod : A positional parameter cannot be found that accepts argument
'2023-02-10T00:00:00&endDateTime=2023-02-12T23:59:59'
I then tired this command:
Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2023-02-10T00:00:00&endDateTime=2023-02-12T23:59:59' -Method Get
I then got this message:
"code": "BadRequest", "message": "Bad Request",
"The DateTimeOffset text '2023-02-10T00:00:00' should be in format
'yyyy-mm-ddThh:mm:ss('.'s+)?(zzzzzz)?' and each field value is within valid range.",
"target": "startDateTime"
Lastly, I tried this command:
Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2023-02-10T00:00:00.000Z&endDateTime=2023-02-12T23:59:59.000Z' -Method Get
I then get this message:
Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {"code": "BadRequest", "message": "Bad Request", "details": [{
"message": "Object must implement IConvertible
Can anyone give the correct syntax to call the Power BI REST API to show the activith from Feb. 10, 2023 - Feb. 12, 2023? Once we have this simple step done we would like to move forward with getting a continuation token and autmating the process with SSIS.
4 Replies
- Lorenz33Helper IV
I am just bumping this up. Maybe the original post is too wordy.
What I need is help accessing the Power BI Activity in order to retrieve audit/tracking data on who is accessing the reports, duration, frequenecy, etc. This article says we can do that using Power BI REST APIs.
https://learn.microsoft.com/en-us/power-bi/admin/service-admin-auditing
Her is info on the Power BI Get Activity Events REST APIs.
Admin - Get Activity Events - REST API (Power BI Power BI REST APIs) | Microsoft Learn
How do I run them from Powershell? I have been trying running the following command:
Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2023-02-10T00:00:00.000Z&endDateTime=2023-02-12T23:59:59.000Z' -Method Get
However, it fails. I have tried adding single quotations around the dates but it just adds it into one big string from the start date to the end date and fails. I have tried removing the .000Z from the end of the dates but it gives a date format error.
Any help would be appreciated.
- odegaardNew Member
Heyyy,
Did you manage to solve this issue?
Can you please, provide more information about this topic?
- JessieFAdvocate II
Hi Lorenz33 ,
Have you use the Feature Usage and Adoption report in the Admin Monitoring workspace? What is the admin monitoring workspace? - Microsoft Fabric | Microsoft Learn
The report itself is helpful, but I built custom reports with the semantic model and it's really helpful to track every kind of activity - viewing reports, exporting reports, viewing via Apps, viewing via Teams interface, creating subscription, running subscription - those are just a few of the activities you can see.
Here's a privatized version of a really active workspace in my tenant
Then I wanted to have a custom report with different options and have some default filters applied - excluding certain operation activities, admin users, etc.
This is my custom version - its just used in a team of 3 admins, so it was designed for function not "fashion"
But we can search by an Activity type - I made a custom category of consumption vs non-consumption to delineate who is doing "pro license user activity" vs just a business consumer.
I can search by workspace, UPN, item name (reports, datasets, dataflows, etc)
Then we can drill through to get report specific activity breakdowns. My team loves using this to get quick stats on activity. But the dataset for it is just from the Feature Usage and Adoption reportIf this seems to solve your problem, I'd be happy to engage further on how we use it and our custom filters.
Jessie. - ThomaslleblancSuper User
Here is the code I use in Powershell that works:
ForEach-Object {
$Date = (((Get-Date).Date).AddDays(-$_))
$StartDate = (Get-Date -Date ($Date) -Format yyyy-MM-ddTHH:mm:ss)
$EndDate = (Get-Date -Date ((($Date).AddDays(1)).AddMilliseconds(-1)) -Format yyyy-MM-ddTHH:mm:ss)
Get-PowerBIActivityEvent -StartDateTime $StartDate -EndDateTime $EndDate -ResultType JsonString |
Out-File -FilePath "$($jobOutputPath)\AuditLog_$(Get-Date -Date $Date -Format yyyyMMdd).json"
Write-Output "Get data." + $Date
}