Forum Discussion

alexgor87's avatar
alexgor87
Icon for Advocate II rankAdvocate II
5 years ago
Solved

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 diff...
  • alexgor87's avatar
    alexgor87
    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

  • alexgor87's avatar
    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"
    }