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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
sb991986
Helper I
Helper I

Get Refresh History for all workspaces via API

Hi,

 

On my tenant, I'm Power BI administrator and Capacity administrator. But I am not administrator on each Workspace.

I need to see all refresh duration of all datasets of my power BI (both premium & non premium), even if I'm not administrator on all workspaces.

 

I tried to get history refresh using the API "Datasets - Get Refresh History In Group", but it seems that I can not get history of datasets refresh  that I'm not the Workspace Administrator.

 

Is there a way to get all history refresh without being workspace Administrator? Because I'm Power BI administrator and Capacity administrator on my tenant. 

 

Thanks for your feedback

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi @sb991986

 

Here is the powershell script that you can use in conjunction with the REST API to get the refresh history of all workspaces.

Connect-PowerBIServiceAccount



$Workspaces = Get-PowerBIWorkspace



foreach($workspace in $Workspaces)
{



$DataSets = Get-PowerBIDataset -WorkspaceId $workspace.Id | where {$_.isRefreshable -eq $true}
foreach($dataset in $DataSets)
{



$URI = "groups/" + $workspace.id + "/datasets/" + $dataset.id + "/refreshes"
#$OutFile = $ExportFolder + '\' + $workspace.Name + '-' + $dataset.Name + '.json'
$Results = Invoke-PowerBIRestMethod -Url $URI -Method Get | ConvertFrom-Json



foreach($result in $Results.value)
{
$errorDetails = $result.serviceExceptionJson | ConvertFrom-Json -ErrorAction SilentlyContinue



$row = New-Object psobject
$row | Add-Member -Name "Workspace" -Value $workspace.Name -MemberType NoteProperty
$row | Add-Member -Name "Dataset" -Value $dataset.Name -MemberType NoteProperty
$row | Add-Member -Name "refreshType" -Value $result.refreshType -MemberType NoteProperty
$row | Add-Member -Name "startTime" -Value $result.startTime -MemberType NoteProperty
$row | Add-Member -Name "endTime" -Value $result.endTime -MemberType NoteProperty
$row | Add-Member -Name "status" -Value $result.status -MemberType NoteProperty
$row | Add-Member -Name "errorCode" -Value $errorDetails.errorCode -MemberType NoteProperty
$row | Add-Member -Name "errorDescription" -Value $errorDetails.errorDescription -MemberType NoteProperty
Write-Host $row
}



}



}

Here is the output:

v-xulin-mstf_0-1623142981298.png

Hope it helps.😉

 

Best Regards,
Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
sb991986
Helper I
Helper I

Thank you. This has been resolved.

Hi,

 

How did you resolve it?

 

I have the same issue, I can only get refresh history for workspaces I have access to, although I'm PBI Administrator.

 

Thank you,

 

WJ

v-xulin-mstf
Community Support
Community Support

Hi @sb991986

 

Is your issue solved?

If the issue has been solved, please adopt your solution to help others.

Thanks! 😉

 

Best Regards,
Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

v-xulin-mstf
Community Support
Community Support

Hi @sb991986

 

Here is the powershell script that you can use in conjunction with the REST API to get the refresh history of all workspaces.

Connect-PowerBIServiceAccount



$Workspaces = Get-PowerBIWorkspace



foreach($workspace in $Workspaces)
{



$DataSets = Get-PowerBIDataset -WorkspaceId $workspace.Id | where {$_.isRefreshable -eq $true}
foreach($dataset in $DataSets)
{



$URI = "groups/" + $workspace.id + "/datasets/" + $dataset.id + "/refreshes"
#$OutFile = $ExportFolder + '\' + $workspace.Name + '-' + $dataset.Name + '.json'
$Results = Invoke-PowerBIRestMethod -Url $URI -Method Get | ConvertFrom-Json



foreach($result in $Results.value)
{
$errorDetails = $result.serviceExceptionJson | ConvertFrom-Json -ErrorAction SilentlyContinue



$row = New-Object psobject
$row | Add-Member -Name "Workspace" -Value $workspace.Name -MemberType NoteProperty
$row | Add-Member -Name "Dataset" -Value $dataset.Name -MemberType NoteProperty
$row | Add-Member -Name "refreshType" -Value $result.refreshType -MemberType NoteProperty
$row | Add-Member -Name "startTime" -Value $result.startTime -MemberType NoteProperty
$row | Add-Member -Name "endTime" -Value $result.endTime -MemberType NoteProperty
$row | Add-Member -Name "status" -Value $result.status -MemberType NoteProperty
$row | Add-Member -Name "errorCode" -Value $errorDetails.errorCode -MemberType NoteProperty
$row | Add-Member -Name "errorDescription" -Value $errorDetails.errorDescription -MemberType NoteProperty
Write-Host $row
}



}



}

Here is the output:

v-xulin-mstf_0-1623142981298.png

Hope it helps.😉

 

Best Regards,
Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

ibarrau
Super User
Super User

Hi, the only way to get all that data is being Power Bi Administrator. It's not necessary for you to be Workspace administrator. There are API Requests that onle the Administrator can do. You can use these two requests first:

Get all workspaces in the tenant:

https://docs.microsoft.com/en-us/rest/api/power-bi/admin/groups_getgroupsasadmin

Get all the datasets in a workspace

https://docs.microsoft.com/en-us/rest/api/power-bi/admin/datasets_getdatasetsingroupasadmin

Once you get all workspaces you can get all the datasets inside them. At the end you can use the get request of the historic refreshes for each dataset.

You will probably need to write a script. 

I hope this helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Anonymous
Not applicable

 

Install the following modules using Windows Powershell ISE if you are new to powershell. Above script works only after these two modules are installed.

Install modules.JPG

 

You can also produce csv file by commenting out and adding following code 

#Write-Host $row
$row | Export-CSV C:\Users\Output\refresh.csv -Append

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.