Forum Discussion
Get-PowerBIActivityEvent retrieving different number of columns
- 5 years ago
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 - 5 years ago
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" }
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"
}