Forum Discussion
Deploying master semantic model to multiple (100) workspaces and editing parameter
- Anonymous2 years ago
Thank you Greg_Deckler
Hi, SuperFiets_
We can use PowerShell commands to deploy the semantic model into multiple workspaces, and as you described, after deployment, you need to leverage the PowerAPI to change the parameters.
In the following, I'll walk you through deploying a PBIX file into multiple workspaces:First, we need to follow the PowerShell command of Power BI:
Install-Module -Name MicrosoftPowerBIMgmtUse the following command to deploy your Main Semantic Model into multiple workspaces:
Connect-PowerBIServiceAccount $Path = "C:\Users\xxxx\Desktop\Protest.pbix" $targetWorkspaceIds = ("xxxx-xxx-xxx-xxx","xxxx-xxx-xxx-xxx","xxxx-xxx-xxx-xxx") foreach($targetWorkspaceIds in $targetWorkspaceIds){ New-PowerBIReport -Path $Path -Name "Testaaa" -WorkspaceId $targetWorkspaceIds }The result returned in PowerShell is as follows:
Check if they were deployed successfully in Power BI:
You can learn about these PowerShell commands from the following connection:
New-PowerBIReport (MicrosoftPowerBIMgmt.Reports) | Microsoft Learn
Since you have more than 100 workspaces, you can consider using the following PowerShell command to list all the workspaces, and then collect the workspace IDs that need to be deployed through PowerShell programming, and then use the above command to deploy with one click.
Get-PowerBIWorkspace -AllBest Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi jianpeng,
Thank you for your answer!
After a lot of errors, googling and gpt'ing I got myself a script that works perfectly fine in PowerShell.
But in essence it is exactly how you described.
My script does the following while using the Power BI REST API:
1. Exports a master dataset into a memory stream, so it won't appoint to a local folder.
2. Imports the master dataset in a parameterized set of workspaces, all workspaces starting with "officeXXX" will be selected.
3. It waits for the import to be completed and saves the datasetID
4. With the saved datasetID it changes a parameter in the dataset dynamically based on the workspace name (workspace name = dataset parameter value).
Last thing I tried is to take over the dataset, but that required OAuth authentication with one of our personal accounts. A better solution we found is implementing a "refresh button" in our main Hub (PowerApps) that dynamically refreshes a dataset with a custom Power Automate flow, which the service principal app will perform.
The final PowerShell script will be commited to a git repo in Azure DevOps which will run the .ps1 file in a pipeline.
Hi, SuperFiets_
You are on the right path. As you mentioned, we can combine PowerShell with other platforms to automate flows.
Best Regards
Jianpeng Li