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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Get-PowerBIActivityEvents returns empty nodes

Powershell script previously working to retrieve activitiy logs using Get-PowerBIActivityEvents cmdlet now returns a large but empty json

 

JonathanFlint_0-1697545703203.png

This is the call I am doing*

 

    $Date = Get-Date

    if (!(Test-Path $FileName -PathType Leaf)) {
        $StartDate = $Date.ToString("yyyy-MM-dd")+"T00:00:00.000Z"
        $EndDate = $Date.ToString("yyyy-MM-dd")+"T23:59:59.999Z"
        $Activity = Get-PowerBIActivityEvents -StartDateTime $StartDate -EndDateTime $EndDate
        $Activity | Out-File -FilePath $FileName
 
When doing an in-line Write-Host on $Activity it shows the same as the saved file. This script was working yesterday and last week when I first created this, has there been an update to the api? Can anyone see the bug here?
 
* I am calling this under a foreach($i in (x..y) ) {} to iterate over a range of dates but its returning the same empty valueless json on all dates, 1 with ~100 nodes, 1 date returns only 2 nodes
1 ACCEPTED SOLUTION
Anonymous
Not applicable

After much trouble shooting the issue seemed to be with using vscode, when I switched to powershell ISE it worked fine. I'm assuming vscode and powershell ISE had some differences in versions of PS or the modules

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

After much trouble shooting the issue seemed to be with using vscode, when I switched to powershell ISE it worked fine. I'm assuming vscode and powershell ISE had some differences in versions of PS or the modules

Anonymous
Not applicable

Hi @Anonymous ,

According to your description, it seems that it only return empty json when call REST API to get activitiy logs. Howevery, before it is working normally. Am I right? To troubleshoot this issue, please follow the steps below:

1. Check the PowerShell module version: Ensure that you are using the latest version of the Power BI PowerShell module.

Update-Module -Name MicrosoftPowerBIMgmt

2. Verify the authentication: Make sure that you are authenticated correctly to access the Power BI service. 

Power BI Cmdlets reference | Microsoft Learn

Connect-PowerBIServiceAccount   # or use aliases: Login-PowerBIServiceAccount, Login-PowerBI

3. Check the date range: Verify that the date range you are specifying is correct and includes the desired activity logs. Double-check the start and end dates in your script.      

4. Test with a single date: To isolate the issue, try running the script with a single date instead of iterating over a range of dates. This will help determine if the issue is specific to the date range or if it persists even with a single date.

Get-PowerBIActivityEvent (MicrosoftPowerBIMgmt.Admin) | Microsoft Learn 

Get-PowerBIActivityEvent -StartDateTime 2019-08-10T14:35:20 -EndDateTime 2019-08-10T18:25:50

Best Regards

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.