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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
alexyin1053
Frequent Visitor

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
v-yohua-msft
Community Support
Community Support

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
v-yohua-msft
Community Support
Community Support

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors