Forum Discussion
No Returned Data from PBI Activity Log
Hi,
I am a PBI service admin, and I am trying to use PowerShell to call the PBI API and return results from the PBI Activity Log. I run the command below and it returns the expected JSON response, however it doesn't return any data. I have all of the auditing and logging options enabled in the "Audit and usage settings", so I should be logging events.
Command:
$activities = Get-PowerBIActivityEvent -StartDateTime '2020-02-26T00:00:00' -EndDateTime '2020-02-26T23:59:59' | ConvertFrom-Json
$activities | Out-File -FilePath C:\Temp\PowerBIAuditLogs\test.csv
Any ideas why I'm not returning data in the response?
2 Replies
- NickA01Resolver III
I see this is an old thread so hopefully you have resolves it:
I had same issue earlier this week and had to change the call to use Invoke-PowerBiRestMethod and am now getting results.
Here's my full script with comments ( I do not find writing code easy so lots of comments and it may not be the best script)# to Do# - Change creds to user Service Principle??# - Change output to --Opt 1 - Write directly to DB - Stage (Nvarchar(Max) -- SP to split Json -- Write to table# - Option 2 Write to BLOB --> ADF to read Blob and write to db.# LoginLogin-PowerBIServiceAccount#var for output pth$PBIEventFilePath = "D:\Repos\PbiAccAudit\"# set var for day$day = Get-date#Initiate day loop $s1 -> this is yesterdayfor ($s = 1; $s -le 3; $s++) {$periodStart = $day.AddDays(-$s)$base = $periodStart.ToString("yyyy-MM-dd")# set hour to required format -- runs from 0 am to 9 AM --Once hr is 2 digit then no issue.for ($h = 00 ; $h -le 23; $h++) {if ($h -le 9 ){ $hh = 'T0' + $h }else { $hh = 'T' + $h }# write-host $base$callStart = 'startDateTime=''' + $base + $hh + ':00:00.000Z'''$callEnd = '&endDateTime=''' + $base + $hh + ':59:59.000Z'''## Single file per hr Path for JSON output file# $fnStart="Activity_"+$callStart.Substring(15,10)+".Json"# $OutoutFile=$PBIEventFilePath+$fnStart# write-host $OutoutFile$fileName = "Activity_" + $base + ".Json"$OutoutFile = $PBIEventFilePath + $fileName#build uri$baseuri = "/admin/activityevents?"$uriStr = $baseuri + $callStart + $callEnd#Write-Host $uriStr#Now set sleep to avoid write errors# $z=0;# Write-Host $uriStr$a = Invoke-PowerBIRestMethod -Url $uriStr -Method Get# use for 1 file per day If = create file || appendIf ($hh -eq "T00"){ $a | Out-File -FilePath $OutoutFile }else { $a | Out-File -FilePath $OutoutFile -Append }# write-host $a# Resolve-PowerBIError -Last}} - v-eachen-msftCommunity Support
Hi Anonymous ,
After my tests, I couldn't reproduce your issues. The feature works properly on my side.
You could create a support ticket here for further help.