Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Powershell script to change Datasource Test to Production

 

Does someone have a powershell script to change the data source?
For example I want deploy my report to powerBI reporting service from Test to Productios therefore i need to change the datasource from
OTA-DWH-01\Test to OTA-DWH-02\Production
I have a lot of reports so doing it manually will take a lot of time. I now have to open each report indivually and change the datasource.

14 Replies

  • mgmeyer's avatar
    mgmeyer
    Power BI Team

    I don't know if there is an existing script for this however it should be pretty straightforward assuming your using Shared DataSources. All you would need to do is issue a PUT request to the following REST API for each of your reports:

     

    http://<server>/reports/api/v2.0/Reports(ID/Path)/DataSources

     

    As for the payload you just need to update the path to the new DataSource. You can refer to the API docs here:

     

    https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0#/Reports/SetReportDataSource

    • Anonymous's avatar
      Anonymous
      Not applicable

      (Responding to fbeekvel)

      Everything I've tried to change the ReportServer connection string, including all 3 articles you've attached. The connection string is local to the file, and the file only. The connection string is read-only in the ReportServer.

       

      I'd love to be proven wrong, but I don't think it's possible. One possible way is to zip the file and change the connection string text, then zip it back up. That's not enterprise-grade though so I haven't pursued it.

      • fbeekvel's avatar
        fbeekvel
        Frequent Visitor
        I'm pretty sure It works. I have a working script somewhere, I'll see if I can post it tomorrow.
    • Anonymous's avatar
      Anonymous
      Not applicable



      Does this also work for power bi report server? because when i look into the script it says i need to get the source report info from powerbi service.

      • CasperLehmann's avatar
        CasperLehmann
        Frequent Visitor
        I don't know how you connect to the report server, there might be differences. But please report back if you do try it out. I would like to know.
    • imichalarias's avatar
      imichalarias
      Frequent Visitor

      Is there any solution to this problem? We are trying to edit a PBIRS DataSource connecting to an on-premise SQL Server database, using the UpdatePowerBIReportDataSource method.

       

      No matter what we edit (database name, server or user), we get a 400 bad request...

       

      Our PBIRS is 15.0.1102.371 (Mai 2019).

      • Anonymous's avatar
        Anonymous
        Not applicable

        To my knowledge, it is only possible with SSAS-based sources. It's certainly not possible with SQL Server databases.

         

        You're able to attempt this with your report by: "Manage"-->"Data sources"-->"Connection string". Try to edit the connection string. It's possible in SSAS but nothing else I've ran into.