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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mmassey1010
Frequent Visitor

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?Capture.PNG

2 REPLIES 2
NickA01
Resolver III
Resolver 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.

# Login
Login-PowerBIServiceAccount
#var for output pth
$PBIEventFilePath = "D:\Repos\PbiAccAudit\"
# set var for day
$day = Get-date

#Initiate day loop  $s1 ->  this is yesterday
for ($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 || append
            If ($hh -eq "T00")
            { $a | Out-File -FilePath $OutoutFile }
            else { $a | Out-File -FilePath $OutoutFile -Append }
           # write-host $a
           # Resolve-PowerBIError -Last
   
    }
}



v-eachen-msft
Community Support
Community Support

Hi @mmassey1010 ,

 

After my tests, I couldn't reproduce your issues. The feature works properly on my side.

2-1.PNG

You could create a support ticket here for further help.

Support Ticket.gif

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.