A few days ago I had to add a new team member to more that 50 workspaces. I started dying inside just thinking of going to each workspace and add it using the portal ui.
Here’s a little snippet that saved me a few hundred clicks:
Login-PowerBI
$workspaces = Get-PowerBIWorkSpace
$user = "mySpecial.User@MyDomain.com"
foreach($workspace in $workspaces)
{
Write-Host "Adding User to : " $workspace.Name
try
{
Add-PowerBIWorkspaceUser -Id $workspace.Id -UserPrincipalName $user -AccessRight Member
}
catch
{
Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red
}
}
Adapt it to your needs.
Have fun!