Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Lorenz33
Helper III
Helper III

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:

https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='2019-08-31T00:00:00'&endDateT...

 

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'&endDateT...'' -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&endDateTim...' -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&endDa...' -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.

1 REPLY 1
Lorenz33
Helper III
Helper III

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&endDa...' -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.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors