Upload Power BI Reports using PowerShell
In this blog post, I will be sharing a PowerShell script that allows multiple Power BI reports to be uploaded at once. In a previous blogpost, I shared a PowerShell script that allowed users to downloaded multiple Power BI reports. Combined you could move several reports from one workspace to another in a few seconds.
The script is downloadable at the bottom of the page as a txt file. To use the script there are three steps to take.
The first step is to install and import the MicrosoftPowerBIMgmt PowerShell module. The following code should do the trick.
The second step is to fill in the variables at the top of the script:
- Workspace Name
- Report Name
- Upload Path
Workspace Name – The name of the workspace in which the report or reports are to be uploaded to.
Report Name – This can be configured to upload one, multiple or all reports in the folder.
One report = @(‘Report 1’)
Multiple reports = @(‘Report 1’, ‘Report 2’, ‘Report 3’)
All reports = @()
Upload Path – The folder where the report or reports are saved.
Conflict – This parameter decides what happens when we upload a report to a workspace, where a report with the same name already exists.
Ignore – Ignores the report already uploaded, this means the workspace ends up with two reports with the same name.
Abort – This errors the code and leaves the already uploaded report.
Overwrite – This overwrites the report already uploaded and replaces it with the new report.
CreateOrOverwrite – As far as I’m aware, this is the same as overwrite. If there is no conflict the upload will always create a new report in the workspace. Please leave a comment if anyone knows there to be a difference.
Once these variables are assigned the script is ready to be executed.
The third and final step is to sign into Power BI, a prompt asking you to sign into Microsoft Azure will pop up. Use the credentials you would use to sign into PowerBI.com.
The script should now run in full and bring the PBIX files into the workspace.
The script is attached as a txt file.