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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply

Retrieving scheduled refresh events using the Power BI API

Hi,

 

We have a requirement to identify failed refreshes in the Power BI service programtically so that we can setup alerts.

 

I'm using the following PowerShell code:

 

Connect-PowerBIServiceAccount

$ActivityDate = '2025-04-17'
$ActivityType = 'RefreshDataset'

# Retrieve the activity events
$response = Get-PowerBIActivityEvent `
    -StartDateTime ($ActivityDate + 'T00:00:00.000') `
    -EndDateTime ($ActivityDate + 'T23:59:59.999') `
    -ActivityType $ActivityType `

Write-Host $response
 
The response includes some refresh events, however scheduled refresh events are omitted (only on demand or via the API are returned).
 
How can I retreive this information programatically?
1 ACCEPTED SOLUTION

Ok thanks, i'll give that a go this week and accept the solution if it works.

View solution in original post

12 REPLIES 12
v-pgoloju
Community Support
Community Support

Hi @SamRobinson120,

 

Thank you for getting back to us and for engaging with the Microsoft Fabric Forum Community.

 

As we haven’t received any further updates and there are no outstanding queries at the moment, we’ll go ahead and close this thread for now. If you have any additional questions in the future, please don’t hesitate to start a new thread we’re always here to help.


Warm regards,
Prasanna Kumar

v-pgoloju
Community Support
Community Support

Hi @SamRobinson120,

 

Just a gentle reminder  has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.

This not only closes the loop on your query but also helps others in the community solve similar issues faster.

Thank you for your time and feedback!

 

Best,

Prasanna Kumar

Hi,

 

I've already responded with the below:

 

We've delayed this work now until a later date so I can't confirm it's an accepted solution at this point.

 

Regards

Sam

v-pgoloju
Community Support
Community Support

Hi @SamRobinson120,

 

Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.

 

Best regards,

Prasanna Kumar

Hi Prasanna,

 

We've delayed this work now until a later date so I can't confirm it's an accepted solution at this point.

 

Regards

Sam

v-pgoloju
Community Support
Community Support

Hi @SamRobinson120,

 

Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.

 

Best regards,

Prasanna Kumar

Hi, we're still looking into this at the moment. Can you confirm which of the event categories listed here show failed scheduled refresh events?

 

https://learn.microsoft.com/en-gb/power-bi/transform-model/log-analytics/desktop-log-analytics-confi...

v-pgoloju
Community Support
Community Support

Hi @SamRobinson120

Thank you for reaching out to the Microsoft Fabric Forum Community.

Also, a big thanks to @Deku  and @andrewsommer  for the prompt and helpful response.

For this scenario, Log Analytics Integration is the most effective solution.

 

Steps to Implement:
1. Enable Log Analytics Integration, Make sure your workspaces are assigned to Power BI Premium or Fabric Capacity. Connect Power BI to Log Analytics through the Admin Portal.

2. Use Kusto Query to Detect Refresh Failures.

3. Set Up Alerts in Azure, Create an Alert Rule based on the query. Configure notifications via Email, Microsoft Teams, Logic Apps, etc.

 

If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.

 

Thank you & regards,
Prasanna Kumar

Ok thanks, i'll give that a go this week and accept the solution if it works.

andrewsommer
Super User
Super User

Using the PBI REST API for model refreshed try this:

# First, authenticate
Connect-PowerBIServiceAccount

# Get all workspaces
$workspaces = Get-PowerBIWorkspace -All

foreach ($ws in $workspaces) {
    $datasets = Get-PowerBIDataset -WorkspaceId $ws.Id
    foreach ($ds in $datasets) {
        $refreshes = Invoke-PowerBIRestMethod -Url "groups/$($ws.Id)/datasets/$($ds.Id)/refreshes" -Method Get | ConvertFrom-Json
        foreach ($r in $refreshes.value) {
            if ($r.status -eq "Failed") {
                Write-Host "FAILED REFRESH FOUND:"
                Write-Host "  Workspace: $($ws.Name)"
                Write-Host "  Dataset: $($ds.Name)"
                Write-Host "  Refresh Type: $($r.refreshType)"
                Write-Host "  Start Time: $($r.startTime)"
                Write-Host "  End Time: $($r.endTime)"
                Write-Host "  Service Exception: $($r.serviceExceptionJson)"
            }
        }
    }
}

 

For dataflows you can use this:

GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/dataflows/{dataflowId}/refreshes

 

Please mark this post as solution if it helps you. Appreciate Kudos.

Hi,

 

Yes I've seen that you can obtain the refresh history for each dataset. The issue is we already have over 1200 workspaces with several datasets that have auto-refresh switched on. I am looking for a solution that doesn't require us to loop through every workspaces and dataset as it can be slow. Activity events seems to get us close, I just don't understand why scheduled refreshes aren't included in the response.

 

Regards

If you have Log Analytics Intergration setup you can look at the command event for the refresh and get the status (succeeded/failed)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.