Forum Discussion

tousinn's avatar
tousinn
Regular Visitor
3 years ago

How to remove the Power BI gateway using PowerShell or REST API

Hi team

 

We are trying to delete Power BI gateway by using PowerShell module or REST API.

 

We tried to use DataGateway PowerShell module to get the gateway first and remove it using the comdlets below.

============================

     $PowerBIDataGatewayCluster = Get-DataGatewayCluster
   
     if ($null -ne $PowerBIDataGatewayCluster -and "" -ne $PowerBIDataGatewayCluster) {
         Write-Host "Revoke admin access for SPN from Power BI gateway $($PowerBIDataGatewayCluster.Name)"
          Remove-DataGatewayCluster -GatewayClusterId $PowerBIDataGatewayCluster.Id
     }

============================

 

It works well with my Azure accounts without any issue.

 

However, if we use the service principal, even if the service principal has the admin access to the PowerBI gateway,

the cmdlet is still not able to get the gateway or remove it. And I am getting unauthoried error.

 

Is that because the Power BI powershell moduel does not support Service Principal authencation?

 

Is there anyway we could automate this process?

 

Thanks!

14 Replies

  • Why would you want to automate that operation?  You don't want to mess with a gateway configuration unless absolutely necessary. Removing a gateway cluster member should be done judiciously (and can be done via the admin center UI too).

    • tousinn's avatar
      tousinn
      Regular Visitor

      Hi lbendlin 

       

      This is a buiness requirement. We have one gateway for each customer and we would like to remove it once the customer is offboarded.

       

      Yes, we noticed that the PowerShell cmdlet is able to remove the members 

       

      But we would like to remove the gateway itself as well, otherwise we will have heaps of gatway without being used anymore.

      • lbendlin's avatar
        lbendlin
        Super User

        If you must - there is a choreography to it.

         

        1. List all gateways and all cluster members

        2. Identify the anchor member

        3. for each gateway, remove the members that are NOT the anchor

        4. remove the anchor member.

         

        Hint:  The gatewayObjectId of the anchor member is the clusterObjectID

         

        Note:  This only removes the meta data on the Power BI Service. It does not do anything to your VMs.