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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
rthomas
Regular Visitor

Get-PowerBIReport : Operation returned an invalid status code 'TooManyRequests'

I'm using the PowerShell Script from https://insightsquest.com/2019/06/19/power-bi-artifact-to-workspace-relationships/, using my userid/pw to return all workspaces, and reports.  essentially looping through all the workspaces to retrieve the reportname, reported, and workspace.  I am getting the output I would expect, but I'm not sure if all the reports are retrieved.

 

$User = "userid@companyname"
$PW = "#useridpassword"

$SecPasswd = ConvertTo-SecureString $PW -AsPlainText -Force
$myCred = New-Object System.Management.Automation.PSCredential($User,$SecPasswd)

Login-PowerBIServiceAccount -Credential $myCred

$RetrieveDate = Get-Date

#1. Define output file paths

$BasePath = "C:\temp\New"

#Export Paths: Power BI Artifacts


$WorkspacesPath = $BasePath + "Workspaces.csv"
$ReportsPath = $BasePath + "Reports.csv"

#2. Get active workspaces excluding personal workspaces ('My Workspace')
$ActiveWorkspaces = Get-PowerBIWorkspace -Scope Organization -All <#| Where-Object {$_.Type -ne "PersonalGroup" -and $_.State -eq "Active"} #> |`
Select-Object *, @{Name="DateRetrieved";Expression={$RetrieveDate}}

#3. Get reports in active workspaces but avoid duplicate reports (due to apps) and exclude usage metrics reports

$Reports = ForEach ($WS in $ActiveWorkspaces)
{
$WSID = $WS.Id
Get-PowerBIReport -Scope Organization -WorkspaceId $WSID | Where-Object {$_.Name -ne "Dashboard Usage Metrics Report" -and $_.Name -ne "Report Usage Metrics Report"} | `
Select-Object Name,DatasetId,@{Name="WorkspaceID";Expression={$WSID}},@{Name="DateRetrieved";Expression={$RetrieveDate}} | `
Sort-Object -Property Name,WorkspaceID | Get-Unique -AsString
}

#4. Export out artifact objects to CSV files for reporting

$ActiveWorkspaces | Export-Csv $WorkspacesPath
$Reports | Export-Csv $ReportsPath

1 REPLY 1
Anonymous
Not applicable

Hi @rthomas 
The 'too many requests' status code would suggest that the API rate limiting is stopping you from getting a complete set of responses. It might be worth trying a short pause within the loop before you call 'Get-PowerBI-Report'

You can get PowerShell to pause by using the 'Start-Sleep' command.

Start-Sleep -Seconds 60

 

I am not suggesting you use 60 seconds between calls. A couple of seconds should probably do it.

 

Cheers, Matt

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.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.