title: Programmatically change the data sources in a Power BI file
body: <p>I need to use PowerShell to change the <strong>paths</strong> of the data sources of a <strong>local</strong> Power BI report file.
  For example, I want to change the data source path from <code>C:\.....\sales.csv</code> to <code>D:\.....\sales_new.csv</code></p>
  <img src="https://i.stack.imgur.com/k07lz.png" width="400" />
  <p>I have found this <a href="https://community.powerbi.com/t5/Desktop/Change-pbix-data-source-programmatically/m-p/129735/highlight/true#M55227" rel="nofollow noreferrer">four-year-old response</a> to a quite similar question.
  I have followed the instructions and it is working quite fine.
  The only problem is that I need to refresh the Power BI report <strong>manually</strong> everytime after I changed the data source paths within the xml-file. With the term &quot;manually refreshing&quot; I mean that someone needs to open each Power BI file and confirm the refreshing of the data sources.</p>
  <p>It is unsatisfying for my customer to manually refresh each Power BI report after altering the data source paths within the xml-file.</p>
  <p>I have also read about the possibility, to change the ending a Power BI report file from *.pbix to *.zip, to extract it and open the &quot;Connections&quot; file to modify the path stored inside this file.</p>
  <img src="https://i.stack.imgur.com/6uWYW.png" width="200" />
  <p>However, when I open the &quot;Connections&quot; file with Notepad, there is no data source path, like <code>C:\.....\sales.csv</code>, in this file.</p>
  <img src="https://i.stack.imgur.com/hAry8.png" height="75" />
  <p>Is there any way how I can programmatically change the data source paths in a <strong>local</strong> Power BI report file without the need to manually refresh the Power BI file after changing the data source path?</p>