Skip to main content
Microsoft Idea

Power BI

Needs Votes

Powershell automation to create new pbix files from templates (pbit files)

Vote (582) Share
Andy's profile image

Andy on 03 Dec 2017 13:56:06

Now that we have pbit files to help create new pbix files quickly it would be great to be able to automate this process.

Perhaps we could have some Powershell commands that would allow you to pass the needed parameters and output a new pbix file.

Comments (75)
Andy's profile image Profile Picture

Jeff Hunt on 06 May 2022 20:06:07

RE: Powershell automation to create new pbix files from templates (pbit files)

Correction to my previous comment. The way I converted PBIX to PBIT leaves one file out of the PBIT that is generated when exporting it from Power BI. This didn't impact my test file, but when I tried it on a complicated dashboard it messed part of it up. Still saves the visualizations, filters, layouts, etc. on the report, but part of the model is lost, so things like measures don't carry over. Not a perfect method, but it's a start, and keeps me from being so worried that I'm going to totally bork something I'm working on and then have even more work to restore it. So we still need Microsoft to put in a command line version of the Export for scripting... :-/

Andy's profile image Profile Picture

Jeff Hunt on 06 May 2022 14:59:50

RE: Powershell automation to create new pbix files from templates (pbit files)

Since MS seems intent on ignoring this and similar requests, I made my own script that automates the conversion from PBIX to PBIT. Turns out that both kinds of file are just simple ZIP files, with the only difference being that PBIX files contain a file within them called DataModel which contains all the data. Removing this file from the ZIP converts it to a PBIT. The below script uses the ReportingServicesTools PowerShell module from MS to download all the files from a Reports Center location (RDL, PBIX and others), uses 7Zip to remove the DataModel files from the PBIX files, renames all PBIX to PBIT, then copies everything to the source control location. Enjoy!# ---Prerequisites--- #
#
#Must enable code execution:
#Set-ExecutionPolicy unrestricted
#
#Needs the following module installed from MS:
#Install-Module -Name ReportingServicesTools

$downloadFolder = "C:\Temp\Backup\ReportsCenter"
$projectFolder = "C:\Projects"

Remove-Item -Path $downloadFolder -recurse -force
New-Item -Path $downloadFolder -ItemType "directory"

$restSession = New-RsRestSession -ReportPortalUri http://ReportCenterURL -RestApiVersion v1.0
Out-RsRestFolderContent -RsFolder "/" -Destination $downloadFolder -WebSession $restSession -RestApiVersion v1.0 -Recurse

if (-not (test-path "$env:C:\Program Files\7-Zip\7z.exe")) {throw "$env:Program Files\7-Zip\7z.exe needed"}
set-alias sevenzip "$env:ProgramFiles\7-Zip\7z.exe"

foreach ($file in Get-ChildItem $downloadFolder\*.pbix -recurse) 
{
sevenzip d -tzip $file datamodel
$newFile = ([String]$File).Replace('.pbix','.pbit')
Rename-Item -Path $file -NewName $newFile 
}

Copy-Item -Path $downloadFolder -Destination $projectFolder -Force -Recurse

Andy's profile image Profile Picture

Bri Gipson on 19 Jan 2022 17:16:20

RE: Powershell automation to create new pbix files from templates (pbit files)

This feature would allow us to finally build a code review in our source control DevOps process because PBIT files can be decompressed into READABLE content.

Andy's profile image Profile Picture

Marko Oja on 16 Dec 2021 13:44:02

RE: Powershell automation to create new pbix files from templates (pbit files)

It's almost 2022. Can we have a solution for version control please? Seriously?

Andy's profile image Profile Picture

David Bridge on 14 Dec 2021 23:32:19

RE: Powershell automation to create new pbix files from templates (pbit files)

The problem with the ideas forum is that there are multiple requests for the same thing with slightly different wording, so this specific version of this request only has 109 votes over 5 years.

The DevOps where I am currently contracted has a size limit of 18MB per file, and the pbix goes over this.
Our solution is the clear the data before publishing. A better solution would be to generate a small test database with for dev and test, which personally I am fan of (over the pbit publish), but I am a consultant, not a business decision maker, and therefore I can only advise my client and not tell them how to spend their money. Like many businesses, they don't want to go through that pain and expense (yet) so we are currently stuck with clearing the data and crossing fingers that the size is small enough.

On a separate note though, if a pbit was pushed then the file comparison would work straight out of DevOps, so we wouldn't need to use ALM for peer review. No help for connect live reports but definitely a bonus for the dataset updates.

Andy's profile image Profile Picture

Sau D on 10 Dec 2021 17:21:38

RE: Powershell automation to create new pbix files from templates (pbit files)

It has been 4 years since this idea was posted.

Bear in mind that Amazon Quicksight already has this feature. Pretty much baked into the foundations - not an after thought.


Read this
https://aws.amazon.com/blogs/big-data/migrate-amazon-quicksight-across-aws-accounts/

Andy's profile image Profile Picture

Sau D on 10 Dec 2021 17:18:02

RE: Powershell automation to create new pbix files from templates (pbit files)

It is impossible to implement a clean CI/CD solution without this capability. As of today, the only option is to manually convert the PBIT to PBIX and save the file to GIT. This is a security nightmare!

Andy's profile image Profile Picture

Sau D on 26 Nov 2021 13:12:14

RE: Powershell automation to create new pbix files from templates (pbit files)

OMG! 2021 is drawing to an end and not commitments from MS to address this. Microsoft appears to be relishing their position of near monopoly.

Andy's profile image Profile Picture

Sau D on 26 Nov 2021 13:10:22

RE: Powershell automation to create new pbix files from templates (pbit files)

Please refer to the list of challenges in this Power BI community post.

Problem 1 - Long waiting time
---------------------------------

I have to manually open the PBIT -->refesh all data (15-20 minutes) --> publish online manually



Problem 2 -Impossible to have a CI/CD
-------------------------------------------

I cannot implement CI/CD solution. I have a PBIT file checked into GIT. I want my CI/CD (Azure Devops) to publish the PBIT to my DEV-Workspace and upon validation, I want my CI/CD to automatically publish to PROD-Workspace.



Problem 3- Solving CI/CD by checking in the PBIX into GIT
----------------------------------------------------------------

We could do convert the PBIT into PBIX (50 MB!) and then store this in GIT. But, this would mean storing customer sensitive data in GIT. We definitely do not want to do.

Andy's profile image Profile Picture

Robert Conacher Conacher on 05 Nov 2021 15:12:58

RE: Powershell automation to create new pbix files from templates (pbit files)

the powershell capability is very weak - vote this item up as well
https://ideas.powerbi.com/ideas/idea/?ideaid=6007df26-413e-ec11-a3ee-281878de4cf8

Merged Idea (7)