How to remove a Service Principal from all Power BI workspaces in one go

In addition to adding a Service Principal to all Power BI workspaces, it is also useful to have a script for removing, right šŸ˜ƒ?

Check out the RemoveServicePrincipalFromPowerBIWorkspaces.ps1 gist on GitHub. It’s also framed below (same script).

Script details

This script will prompt for the (correct) ObjectId of the Service Principal (the one from “Enterprise applications” in Azure Active Directory), and it will prompt for the credentials of a Power BI Service Administrator.

Before you run the script, you can specify:

  • If you want the Service Principal to be removed from workspaces in shared or premium capacity or both.

Important notes/disclaimers

Before running this script, make sure you read this first:

  • Note: this script only works with v2 workspaces (you can’t add a Service Principal to a v1 workspace).

Pass the sauce
More from Dave Ruijter

How To Trigger A Power BI Dataset Refresh Using An Azure Data Factory Web Activity

I got a few questions lately on how to integrate the refresh...
Read More

Leave a Reply

Your email address will not be published. Required fields are marked *