Forum Discussion
Retrieving scheduled refresh events using the Power BI API
- 1 year ago
Ok thanks, i'll give that a go this week and accept the solution if it works.
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
- Deku1 year agoSuper User
If you have Log Analytics Intergration setup you can look at the command event for the refresh and get the status (succeeded/failed)