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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Get-PowerBIActivityEvents returns a list of objects with empty list attributes

I have the following code: 

$start = (Get-Date).AddHours(-10).ToString("yyyy-MM-ddTHH:mm:ss")
    $end = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ss")

    # Don't pipe through Out-String or ConvertFrom-Json
    $activities = Get-PowerBIActivityEvent `
        -StartDateTime $start `
        -EndDateTime $end `
        -ActivityType 'ViewReport' `
        -ErrorAction Stop | ConvertFrom-Json

    $activities[0]

That outputs the following:

Id                       : {}
RecordType               : {}
CreationTime             : {}
Operation                : {}
OrganizationId           : {}
UserType                 : {}
UserKey                  : {}
Workload                 : {}
UserId                   : {}
ClientIP                 : {}
UserAgent                : {}
Activity                 : {}
ItemName                 : {}
WorkSpaceName            : {}
DatasetName              : {}
ReportName               : {}
CapacityId               : {}
CapacityName             : {}
WorkspaceId              : {}
ObjectId                 : {}
DatasetId                : {}
ReportId                 : {}
ArtifactId               : {}
ArtifactName             : {}
IsSuccess                : {}
ReportType               : {}
RequestId                : {}
ActivityId               : {}
DistributionMethod       : {}
ConsumptionMethod        : {}
ArtifactKind             : {}
RefreshEnforcementPolicy : {}
BillingType              : {}

I am trying to figure out why I am getting objects for which each attribute is just an empty list. I have followed the official documentation for this Cmdlet but I can't figure out why this is happening. 
I've also tried not using ConvertFrom-Json and just log the Json string. However, I get the same result. 

Documentation I'm following: Access the Power BI activity log - Power BI | Microsoft Learn

1 ACCEPTED SOLUTION

Hi @Anonymous ,

Thank you for reaching out to Microsoft Fabric Community Forum.

 

The error you're getting from Get-PowerBIActivityEvents means your current Power BI account doesn't have the required admin privileges to access activity log data.

You must have :

  • Power BI Service Administrator OR

  • Office 365 Global Administrator

If you're not one of these, you'll need to request access from your IT/Admin team.

 

Regards,

Chaithanya.

View solution in original post

10 REPLIES 10
v-kathullac
Community Support
Community Support

Hi @Anonymous  ,

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.


Regards,

Chaithanya.

Deku
Super User
Super User

You might need to add milliseconds to datetimes string to make it valid


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Good idea, I changed the dates as such:

$start = (Get-Date).AddHours(-10).ToString("yyyy-MM-ddTHH:mm:ss.fff")
$end = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ss.fff")

 I still get the same output though

Does it work without the activitytype filter? 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Even without the activity filter, I get the same result.

Think either the dates are misformed or no data in the period. 

 

Try outputting the datetimes strings to sense check. Also try looking back a full 30 days, without a activitytype file


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

Updated the code as such:

$start = (Get-Date).AddDays(-30).ToString("yyyy-MM-ddTHH:mm:ss.fff")
$end = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ss.fff")
Write-Host $start to $end
$activities = Get-PowerBIActivityEvent `
        -StartDateTime $start `
        -EndDateTime $end | ConvertFrom-Json `
        -ErrorAction Stop
$activities

I get the following output and error:

2025-03-16T08:15:00.598 to 2025-04-15T08:15:00.599
Get-PowerBIActivityEvent : Operation returned an invalid status code 'BadRequest'
At C:\Users\jafarip\OneDrive - TC TC\Desktop\DV-RD\Scripts\Get-MigrationActivityEvents.ps1:7 char:19
+     $activities = Get-PowerBIActivityEvent `
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...BIActivityEvent:GetPowerBIActivityEvent) [Get-PowerBIActivityEvent], HttpOperationExcep  
   tion
    + FullyQualifiedErrorId : Operation returned an invalid status code 'BadRequest',Microsoft.PowerBI.Commands.Admin.GetPowerBIActivityEvent

It's becasue the Cmdlet doesn't work with long time ranges (30 days). I tested that it works with max half a day worth of range.  

Hi @Anonymous ,

Thank you for reaching out to Microsoft Fabric Community Forum.

 

The error you're getting from Get-PowerBIActivityEvents means your current Power BI account doesn't have the required admin privileges to access activity log data.

You must have :

  • Power BI Service Administrator OR

  • Office 365 Global Administrator

If you're not one of these, you'll need to request access from your IT/Admin team.

 

Regards,

Chaithanya.

This is a wrapper on the Get Activity Events API. Make sure you are fabric admin or using a service principal with delegated permissions. 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Anonymous
Not applicable

If I didn't have fabric admin role, I think I would have gotten 403 unauthorized but now I'm just getting bad request. Can you confirm if this is true?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.