A few weeks ago one of my colleagues showed me a PowerShell script to export all Power BI reports from a Power BI Workspace. This could come in handy for back-up purposes (version control is still hard to accomplish) or if you don’t have access to the PBIX files via the normal way and you need to do some edits. The original file can be found here.
I made some changes to the original file to download all reports, from all workspaces and put them in a nice folder structure, with the same names as your workspaces. Of course, it’s still possible to limit the download to only one workspace and one report. Here we go.
With the comments inside the script, I already explain step-by-step how it works. Now I just add some screenshots to show whats happening!
As you can see in the picture above, I decided to download all my reports, from all my workspaces. Some reports aren’t available for download, for example, when incremental refresh is enabled. So far I’ve encountered the following operation failures: Forbidden, BadRequest, NotFound and Unauthorized. The incremental refresh report gave me a BadRequest, and two Usage Metrics report, which I didn’t create, were NotFound. Makes sense, but I’m not sure how they got indexed in the first place. The Unauthorized one is a Microsoft 365 Usage Analytics report. That’s an app from AppSource and while writing this article, you aren’t able to download these pbix files. Now the Forbidden one. I’ts a copy of an incremental refresh dataset, and has no data inside. I’m not completely sure how I got it there in the first place. But that there is something wrong with it, that’s for sure ;).
Here you can see the results of the final step of the script:
And here is my folder structure. As you can see I ran it on the 29th of January and the first of February:
I really hope this script will come in handy for those who need it! With the different options to download All reports, from all workspaces or all reports in one workspace or one report in one workspace, you have a lot of freedom to adjust it to your needs!
Take care.
This is super helpful. I am getting a timeout error for a couple of the dashboards though. I need to find some way to set the timeout.
LikeLike
It works like magic. I downloaded all 12 pbix within 15 min. while downloading them individually takes hours
LikeLike
Only 1 out 82 report was not able to download using this script. This is awesome! Thank you!
LikeLike
This is really useful – Thank You! I do have a question – is there a way to filter out reports that include datasets, so I essentially leave the bigger models, and only backup the reports?
LikeLike
This saved hours. Thank you so much!
LikeLiked by 1 person
Amazing, thank you, very useful!
LikeLike
I want to migrate one report from one workspace to multiple workspaces in power bi. Could you please post the power shell script for this.
LikeLike
Hi Sandeep Singh Verma,
I’m not really an expert on the PowerShell Cmdlets, but you can try to modify this one:
https://learn.microsoft.com/en-us/powershell/module/microsoftpowerbimgmt.reports/copy-powerbireport?view=powerbi-ps
I hope this helps!
LikeLike
This is a great tool that I had been using until it got accidently deleted. Trying to get it working again and I’m having an issue where it’s erroring on “Report Usage Metrics Report” that doesn’t exist in the workspace. I can’t figure out how to filter it out nor can I figure out how to make the download ignore errors and continue. Any suggestions?
Export-PowerBIReport : Operation returned an invalid status code ‘NotFound’
At line:72 char:4
+ Export-PowerBIReport –WorkspaceId $Workspace.ID –Id $Repo …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power…rtPowerBIReport:ExportPowerBIReport) [Export-PowerBIReport], HttpOperationException
+ FullyQualifiedErrorId : Operation returned an invalid status code ‘NotFound’,Microsoft.PowerBI.Commands.Reports.ExportPowerBIReport
LikeLike
I’m sorry Jim,
As mentioned below, I’m not a real expert on the PowerShell part. The script that I posted continues whenever it can’t find a file.
LikeLike
Thanks Erik. Shortly after I posted that message, I found a fix, but couldn’t edit or delete my comment. If anyone else has that issue, you need to add -ErrorAction Ignore at the end of the line that starts with Export-PowerBIReport
LikeLiked by 1 person
Great post, thank you! What is the permission required to download files? Does any user with Pro license can download? Thank you.
LikeLike
Hi Anusha,
You need to have access to the workspace and have at least contributer role. So actually the same as downloading a file from the workspace manually.
LikeLike
Hi,
Great post, very helpful.
Any idea how to adapt the code to download PBIP files rather than PBIX?
Thanks
LikeLike
The key player in this process is a little magic called PowerShell. The article provides a handy script you can adapt to your needs. It basically retrieves all reports from your chosen workspace and downloads them as PBIX files (the native Power BI file format).
LikeLike
Hi Erik, this is great thank you. Do you know if you are able to download the semantic models using a similar script? I have checked the Microsoft Documentation for Power Shell and Power BI and there doesn’t appear to be an option. Just wondered if anyone knew if this was possible?
Thanks a lot,
Richard
LikeLike
Hi Richard,
As far as my knowledge goes, I don’t think you can. If you are on a Premium/Fabric WS, you can however use external tools to connect to that model.
Best regards,
Erik
LikeLiked by 1 person
Thanks a lot, Erik
LikeLiked by 1 person