Change data source connection strings in Power BI reports with PowerShell - Power BI Report Server pre-October 2020
You can change data source connection strings of Power BI reports hosted in Power BI Report Server by using PowerShell to interact with the necessary APIs.
If you're using the latest version of Power BI Report Server, see Change data source connection strings in Power BI reports with PowerShell - Power BI Report Server.
Currently this functionality only works for DirectQuery. Support for import and data refresh is coming.
Install the Power BI Report Server PowerShell commandlets. Find the commandlets and installation instructions at https://github.com/Microsoft/ReportingServicesTools.
ReportingServicesToolsmodule directly from the PowerShell Gallery using the following command.
Fetch the existing data source information for the Power BI file via the PowerShell commandlets:
$dataSources = Get-RsRestItemDataSource -RsItem '/MyPbixReport'
To view information for the first data source contained in the Power BI report:
Update connection and credential info as needed. If updating the connection string and the data source makes use of stored credentials, you need to provide the account password.
To update a data source connection string:
$dataSources.ConnectionString = 'data source=myCatalogServer;initial catalog=ReportServer;persist security info=False'
To change the data source credential type:
$dataSources.DataModelDataSource.AuthType = 'Integrated'
To change the data source username/password:
$dataSources.DataModelDataSource.Username = 'domain\user'
$dataSources.DataModelDataSource.Secret = 'password'
Save the updated credentials back to the server.
Set-RsRestItemDataSource -RsItem '/MyPbixReport' -RsItemType 'PowerBIReport' -DataSources $dataSources
Paginated report data sources in Power BI Report Server
More questions? Try asking the Power BI Community
Submit and view feedback for