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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
alexgor87
Advocate II
Advocate II

Get-PowerBIActivityEvent retrieving different number of columns

While I was developing the script with Get-PowerBIActivityEvent I noticed that the same script might retrieve different results.
Here's the test: retrieving logs for the same day 7 times into 7 different CSV-files:

 

foreach ($i in 1..7) {
(Get-PowerBIActivityEvent -StartDateTime 2021-01-22T00:00:00 -EndDateTime 2021-01-22T23:59:59 -ResultType JsonString |
ConvertFrom-Json) | Select * |
Export-Csv -NoTypeInformation -Path "C:\Audit_Logs\PowerBI_AuditLog_$($i).csv"
}

 

Update: PowerShell version 5.1.18362.1171, MicrosoftPowerBIMgmt version 1.0.896.

The number of columns in the output files is different. For example, here's the comparison of the columns from the two files PowerBI_AuditLog_2.csv (417KB) and PowerBI_AuditLog_3.csv (444KB). Any ideas why this happens? Thanks
image.pngimage.png

2 ACCEPTED SOLUTIONS

Thanks for reply @v-lionel-msft. I run the script for one user as you suggested and - yes, the number of columns for the single user can be different. My observations:
1. The sort order of the retrieved log records is always different.
2. Get-PowerBIActivityEvent returns Json string or object with the columns that have values (HasValues=True) only, which means it can return 17 columns or 28 depending on the particular log record.
3. After ConvertFrom-JSON and Export-CSV the output file structure is defined by the first exported record. Conclusion: considering that the sort order is always random - the file structure is always random too.

Is it possible to pre-define the output result structure before export, for example somewhere around 'SELECT * ' ?
Thanks

View solution in original post

alexgor87
Advocate II
Advocate II

Update: for those who need a full list of Audit Log columns - this is what I figured out, hope it will help:

 

 

foreach ($i in 1..7) {
(Get-PowerBIActivityEvent -StartDateTime 2021-01-22T00:00:00 -EndDateTime 2021-01-22T23:59:59 -ResultType JsonString |
ConvertFrom-Json) |
Select Id, RecordType, CreationTime, Operation, OrganizationId, UserType, UserKey, Workload, UserId, ClientIP, UserAgent, Activity, ItemName, WorkSpaceName, DatasetName, ReportName, CapacityId, CapacityName, WorkspaceId, ObjectId, DataflowId, DataflowName, AppName, DataflowAccessTokenRequestParameters, DatasetId, ReportId, IsSuccess, DataflowType, ReportType, RequestId, ActivityId, AppReportId, DistributionMethod, ConsumptionMethod |
Export-Csv -NoTypeInformation -Path "C:\Audit_Logs\PowerBI_AuditLog_$($i).csv"
}

 

 

View solution in original post

4 REPLIES 4
alexgor87
Advocate II
Advocate II

Update: for those who need a full list of Audit Log columns - this is what I figured out, hope it will help:

 

 

foreach ($i in 1..7) {
(Get-PowerBIActivityEvent -StartDateTime 2021-01-22T00:00:00 -EndDateTime 2021-01-22T23:59:59 -ResultType JsonString |
ConvertFrom-Json) |
Select Id, RecordType, CreationTime, Operation, OrganizationId, UserType, UserKey, Workload, UserId, ClientIP, UserAgent, Activity, ItemName, WorkSpaceName, DatasetName, ReportName, CapacityId, CapacityName, WorkspaceId, ObjectId, DataflowId, DataflowName, AppName, DataflowAccessTokenRequestParameters, DatasetId, ReportId, IsSuccess, DataflowType, ReportType, RequestId, ActivityId, AppReportId, DistributionMethod, ConsumptionMethod |
Export-Csv -NoTypeInformation -Path "C:\Audit_Logs\PowerBI_AuditLog_$($i).csv"
}

 

 

v-lionel-msft
Community Support
Community Support

Hi @alexgor87 ,

 

Yes, you can. Please refer to the sample.

Access the Power BI activity log 

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

v-lionel-msft
Community Support
Community Support

Hi @alexgor87 ,

 

So strange! Try to get the activity log of the specified user.

v-lionel-msft_0-1611730345559.png

foreach ($i in 1..7) {
(Get-PowerBIActivityEvent -StartDateTime 2021-01-22T00:00:00 -EndDateTime 2021-01-22T23:59:59 -User admin@contoso.com -ResultType JsonString |
ConvertFrom-Json) | Select * |
Export-Csv -NoTypeInformation -Path "C:\Audit_Logs\PowerBI_AuditLog_$($i).csv"
}

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks for reply @v-lionel-msft. I run the script for one user as you suggested and - yes, the number of columns for the single user can be different. My observations:
1. The sort order of the retrieved log records is always different.
2. Get-PowerBIActivityEvent returns Json string or object with the columns that have values (HasValues=True) only, which means it can return 17 columns or 28 depending on the particular log record.
3. After ConvertFrom-JSON and Export-CSV the output file structure is defined by the first exported record. Conclusion: considering that the sort order is always random - the file structure is always random too.

Is it possible to pre-define the output result structure before export, for example somewhere around 'SELECT * ' ?
Thanks

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.