Automate Power BI Gateway installation and configuration

Automate Power BI Gateway installation and configuration

Power BI has introduced a new PowerShell cmdlets which enable automation of On-Premises Gateway installation.

In this post, we will walk-through how to install and configure Power BI gateway using PowerShell cmdlets. These cmdlets require PowerShell 7 or higher.

Before we begin, you will see that I have published a report using On-Premises datasource to Power BI service, but there is no Gateway configured to refresh the dataset.

Let’s walk-through the steps:

Install-DataGateway -AcceptConditions

Add-DataGatewayCluster -Name “RukiaCee” -RecoveryKey (Read-Host “Enter Recovery Key” -AsSecureString)

This will give you the GatewayID, GatewayObjectID Gateway Name and Gateway Type.

Set-DataGatewayClusterDatasource -GatewayClusterId e6144066-4f56-4987-96cf-6c930ffeeefa -GatewayClusterDatasourceId 0364daac-9daa-4119-b440-3857d4504cf0″ -DatasourceName “Sales”

The GatewayClusterID(GatewayObjectID), DatasourceID and the Datasource Name are required to add a datasource to the gateway.

After running this command, the data source called Sales and its settings will be added to the Gateway cluster as seeing below.

Add user as an Admin to the gateway: $userToAdd = “Object ID”

Add-DataGatewayClusterUser -GatewayClusterId e6144066-4f56-4987-96cf-6c930ffeeefa -PrincipalObjectId $userToAdd -AllowedDataSourceTypes $null -Role Admin

After running the above command the user with the associated object ID will be added to the Gateway as an Admin as seeing below.

All set! The gateway has been installed and configured all via PowerShell, The Report is now scheduled to refresh.

Script used in walk-through

# Install the package 

   Install-Module -Name DataGateway

#Connect to the Gateway Service

  Connect-DataGatewayServiceAccount

# Install the Gateway and accept terms and conditions

Install-DataGateway -AcceptConditions

# Add a new Data Gateway cluster and provide a recovery key

Add-DataGatewayCluster -Name “RukiaCee” -RecoveryKey (Read-Host “Enter Recovery Key” -AsSecureString)

# Add Data source to the Gateway and set the properties

Set-DataGatewayClusterDatasource -GatewayClusterId e6144066-4f56-4987-96cf-6c930ffeeefa -GatewayClusterDatasourceId 0364daac-9daa-4119-b440-3857d4504cf0″ -DatasourceName “Sales”

# Add user as an Admin to the gateway

$userToAdd = “Object ID”

Add-DataGatewayClusterUser -GatewayClusterId e6144066-4f56-4987-96cf-6c930ffeeefa -PrincipalObjectId $userToAdd -AllowedDataSourceTypes $null -Role Admin

Happy Scripting 🙂

2 thoughts on “Automate Power BI Gateway installation and configuration

  1. Hi Ruki, thanks for the post.
    I’m trying to add data source to the gateway. Where do I get the data source and the gateway clusterid?

Comments are closed.

Comments are closed.