Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
alexyin1053
Helper I
Helper I

Change data source connection strings with PowerShell in other IP address

Dear all,

 

Currently we're running Report Server on our local server, while we need to change the data source connection strings from testing data to product data.

 

After some research, we find a possible solution: Change data source connection strings with PowerShell - Power BI | Microsoft Learn

 

 While we can only succesfully run the powershell command on the Report Server environment, is it possible to use the same powershell command on another IP address(eg., company's personal desktop)?

Any advice or suggestions would be great.

Thanks!

 

Best Regards,

Alex

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @alexyin1053 

You can run PowerShell commands on different IP addresses, such as your company's personal desktop, to change the data source connection string. However, you need to pay attention to the firewall and network configuration.
Make sure the necessary ports are open on the firewall (default is 5985 for HTTP and 5986 for HTTPS) to allow remote PowerShell connections. Also verify that your network policy allows remote connections to the report server.
Also make sure that the user account you're using has the necessary permissions to execute PowerShell scripts on the report server.

Make sure PowerShell Remoting is enabled on the report server. You can enable it on the server with the following command:

Enable-PSRemoting -Force

On your personal desktop, you can use the Invoke-Command cmdlet to run PowerShell scripts on a remote server

$session = New-PSSession -ComputerName "ReportServerIP" -Credential (Get-Credential)
Invoke-Command -Session $session -ScriptBlock {
    # Your PowerShell script to change the connection string
}
Remove-PSSession -Session $session

vyohuamsft_0-1727317579196.png

 

A PowerShell script that changes the connection string of a data source might look like this

$dataSource = Get-RsDataSource -ReportServerUri "http://ReportServerIP/ReportServer" -Path "/path/to/report"
$dataSource.ConnectionString = "data source=ProductDataServer;initial catalog=ProductDatabase;persist security info=False"
Set-RsDataSource -ReportServerUri "http://ReportServerIP/ReportServer" -Path "/path/to/report" -DataSource $dataSource

You can refer to it.

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi, @alexyin1053 

You can run PowerShell commands on different IP addresses, such as your company's personal desktop, to change the data source connection string. However, you need to pay attention to the firewall and network configuration.
Make sure the necessary ports are open on the firewall (default is 5985 for HTTP and 5986 for HTTPS) to allow remote PowerShell connections. Also verify that your network policy allows remote connections to the report server.
Also make sure that the user account you're using has the necessary permissions to execute PowerShell scripts on the report server.

Make sure PowerShell Remoting is enabled on the report server. You can enable it on the server with the following command:

Enable-PSRemoting -Force

On your personal desktop, you can use the Invoke-Command cmdlet to run PowerShell scripts on a remote server

$session = New-PSSession -ComputerName "ReportServerIP" -Credential (Get-Credential)
Invoke-Command -Session $session -ScriptBlock {
    # Your PowerShell script to change the connection string
}
Remove-PSSession -Session $session

vyohuamsft_0-1727317579196.png

 

A PowerShell script that changes the connection string of a data source might look like this

$dataSource = Get-RsDataSource -ReportServerUri "http://ReportServerIP/ReportServer" -Path "/path/to/report"
$dataSource.ConnectionString = "data source=ProductDataServer;initial catalog=ProductDatabase;persist security info=False"
Set-RsDataSource -ReportServerUri "http://ReportServerIP/ReportServer" -Path "/path/to/report" -DataSource $dataSource

You can refer to it.

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.