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

Leave a Reply