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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Get PBIX files as admin

Hello,
I'm trying to use a powershell script to fetch all workspaces using:

 

 

Invoke-PowerBIRestMethod -Url "/admin/groups?%24top=3000" -Method Get | ConvertFrom-Json

 

 

Then checking for each group received for reports inside, using:

 

 

Invoke-PowerBiRestMethod -url ("admin/groups/" + $group.id + "/reports") -method get | ConvertFrom-Json

 

 

I was then unable to find a method to retrieve the pbix files using the API, so I resorted to:

 

 

Export-PowerBiReport -ID $report.id -OutFile ($v_pbixfilepath + $group.name + "\" + $report.name + ".pbix")

 

 

Which just then leads me to this error:

 

 

Export-PowerBiReport : Operation returned an invalid status code 'NotFound'

 

 

 

This may be because my user, a global admin, is not introduced in the workspaces where the reports are. However, I've tried to use an automatic way to add the user by the Add-UserAsAdmin method, but I get a 400 Bad Request. This can be due to my payload, but some workspaces work.

I'm stumped and I'd like to know if I'm approaching this correctly or there's no way of doing this through the API and should do it manually/other way instead. Thank you.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Couldn't get the files through admin, however using this API call (which I missed) allowed me to get the reports within that workspace. However, the user needs to be in the workspace.

 

https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exportreportingroup

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Couldn't get the files through admin, however using this API call (which I missed) allowed me to get the reports within that workspace. However, the user needs to be in the workspace.

 

https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exportreportingroup

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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