A task I’ve had to do a countless number of times is to setup a new Workspace in the Power BI service, and then copy all (or nearly all) the contents of an existing Workspace over to that new Workspace. This is such a common task that the Power BI team went ahead and wrote a blog post on “Duplicating workspaces by using Power BI cmdlets” earlier this year.
However, one detail they left out of that post is how to clone the users & groups, and their respective permissions from one Workspace to another. It’s a pretty simple thing to do, with one not-completely-obvious quirk to it.
Currently, you have to be a Power BI Admin in order to retrieve the list of users/groups & their permission levels. If you are one, the rest is pretty straight forward. Just make sure you have the MicrosoftPowerBIMgmt module installed, run Login-PowerBI, then run the script below.
There is one unfortunate kink to the script above. You’ll notice this line WHERE { $_.AccessRight -ne ‘Viewer‘ } in there because at this time, the Add-PowerBIWorkspaceUser cmdlet doesn’t handle adding a user and granting them the new Viewer role. I have already filed an issue in the GitHub repo for the Power BI PowerShell cmdlets. Please feel-free to comment & Up-Vote this issue if you need this fixed too.
That’s pretty much it for now, I hope this helps!
The post Quick Blog: Clone Power BI Workspace Permissions first appeared on SQLvariations: SQL Server, a little PowerShell, maybe some Power BI.