Forum Discussion
sb991986
5 years agoAdvocate 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 pre...
- 5 years ago
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:
Hope it helps.😉
Best Regards,
LinkIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.