Exporting all your Power BI reports at once

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.

#Log in to Power BI Service
LoginPowerBI Environment Public
#First, Collect all (or one) of the workspaces in a parameter called PBIWorkspace
$PBIWorkspace = Get-PowerBIWorkspace # Collect all workspaces you have access to
#$PBIWorkspace = Get-PowerBIWorkspace -Name 'My Workspace Name' # Use the -Name parameter to limit to one workspace
#Now collect todays date
$TodaysDate = Get-Date Format "yyyyMMdd"
#Almost finished: Build the outputpath. This Outputpath creates a news map, based on todays date
$OutPutPath = "C:\PowerBIReportsBackup\" + $TodaysDate
#Now loop through the workspaces, hence the ForEach
ForEach($Workspace in $PBIWorkspace)
#For all workspaces there is a new Folder destination: Outputpath + Workspacename
$Folder = $OutPutPath + "\" + $Workspace.name
#If the folder doens't exists, it will be created.
If(!(Test-Path $Folder))
New-Item ItemType Directory Force Path $Folder
#At this point, there is a folder structure with a folder for all your workspaces
#Collect all (or one) of the reports from one or all workspaces
$PBIReports = Get-PowerBIReport WorkspaceId $Workspace.Id # Collect all reports from the workspace we selected.
#$PBIReports = Get-PowerBIReport -WorkspaceId $Workspace.Id -Name "My Report Name" # Use the -Name parameter to limit to one report
#Now loop through these reports:
ForEach($Report in $PBIReports)
#Your PowerShell comandline will say Downloading Workspacename Reportname
Write-Host "Downloading "$Workspace.name":" $Report.name
#The final collection including folder structure + file name is created.
$OutputFile = $OutPutPath + "\" + $Workspace.name + "\" + $Report.name + ".pbix"
# If the file exists, delete it first; otherwise, the Export-PowerBIReport will fail.
if (Test-Path $OutputFile)
Remove-Item $OutputFile
#The pbix is now really getting downloaded
Export-PowerBIReport WorkspaceId $Workspace.ID Id $Report.ID OutFile $OutputFile

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!

First I’m asked to sign into Power BI
First I’m asked to sign into Power BI
PowerShell replies with my Tenant Information
PowerShell replies with my Tenant Information
Continuing with the code
Continuing with the code

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:

Downloading notification in PowerShell
Downloading notification in PowerShell

And here is my folder structure. As you can see I ran it on the 29th of January and the first of February:

Folder structure in Explorer
Folder structure in Explorer

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.

Categories Power BI, PowerShell

4 thoughts on “Exporting all your Power BI reports at once

  1. 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.


  2. It works like magic. I downloaded all 12 pbix within 15 min. while downloading them individually takes hours


  3. Only 1 out 82 report was not able to download using this script. This is awesome! Thank you!


  4. robbiefrancis 6 January 2023 — 12:15

    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?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close