<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to batch update CSV data source paths in deployed Power BI Report Server .pbix files? in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4681556#M40569</link>
    <description>&lt;P class=""&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm currently working with Power BI Report Server and have over 300 deployed .pbix reports that connect to CSV files via UNC paths like:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; \\hostnameA\folder\subfolder\file.csv&lt;BR /&gt;I need to &lt;STRONG&gt;batch update all these paths&lt;/STRONG&gt; to:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; \\hostnameB\folder\subfolder\file.csv&lt;/P&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":magnifying_glass_tilted_left:"&gt;🔍&lt;/span&gt; What I've tried:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;I used the Report Server REST API (/PowerBIReports(id)/DataSources) to list and patch the data sources.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;For embedded .pbix reports, I can retrieve the ConnectionString, but fields like Name, Path, and DataSourceType are null.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;When I try to send a PATCH request with updated connection strings, I get: 「400 Bad Request」&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":question_mark:"&gt;❓&lt;/span&gt;My Questions:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;P class=""&gt;Is there an &lt;STRONG&gt;official or recommended way to update CSV file paths in deployed .pbix reports in bulk&lt;/STRONG&gt;?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Is it possible to do this &lt;STRONG&gt;without manually opening each .pbix in Power BI Desktop and re-saving&lt;/STRONG&gt;?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Would converting the embedded data sources to &lt;STRONG&gt;shared data sources (.rsds)&lt;/STRONG&gt; help with future automation?&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P class=""&gt;Thanks in advance for any advice or workaround!&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;PowerShell Script&lt;/P&gt;&lt;P&gt;#script&lt;/P&gt;&lt;P&gt;$server = "&lt;A href="http://hostname" target="_blank"&gt;http://hostname&lt;/A&gt;" # Do not include /reports&lt;BR /&gt;$apiBase = "$server/reports/api/v2.0"&lt;BR /&gt;$oldHost = "\\hostnameA"&lt;BR /&gt;$newHost = "\\hostnameB"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Get all Power BI reports&lt;BR /&gt;$reports = Invoke-RestMethod -Uri "$apiBase/PowerBIReports" -UseDefaultCredentials&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;foreach ($report in $reports.value) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $reportId = $report.Id&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $reportName = $report.Name&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; # Get data sources for the report&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $dataSourcesUrl = "$apiBase/PowerBIReports($reportId)/DataSources"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $dataSources = Invoke-RestMethod -Uri $dataSourcesUrl -UseDefaultCredentials&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; $updateNeeded = $false&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $updateDetails = @()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; foreach ($ds in $dataSources.value) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $oldConnStr = $ds.ConnectionString&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Check if old hostname is present&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($oldConnStr -like "*$oldHost*") {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $newConnStr = $oldConnStr -replace [regex]::Escape($oldHost), $newHost&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "`n[$reportName] Updating connection string:" -ForegroundColor Cyan&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "Original: $oldConnStr"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "Updated : $newConnStr" -ForegroundColor Yellow&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Prepare updated datasource object&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $updateDetails += @{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataSourceType = $ds.DataSourceType&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ConnectionString = $newConnStr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name = $ds.Name&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Path = $ds.Path&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $updateNeeded = $true&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if ($updateNeeded) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $body = @{ value = $updateDetails } | ConvertTo-Json -Depth 10&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Send PATCH request to update the data source&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $patchUrl = "$apiBase/PowerBIReports($reportId)/DataSources"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Invoke-RestMethod -Method Patch -Uri $patchUrl -UseDefaultCredentials -Body $body -ContentType "application/json"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "✔ Data sources updated for report [$reportName]" -ForegroundColor Green&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Tue, 06 May 2025 08:35:50 GMT</pubDate>
    <dc:creator>A111462</dc:creator>
    <dc:date>2025-05-06T08:35:50Z</dc:date>
    <item>
      <title>How to batch update CSV data source paths in deployed Power BI Report Server .pbix files?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4681556#M40569</link>
      <description>&lt;P class=""&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm currently working with Power BI Report Server and have over 300 deployed .pbix reports that connect to CSV files via UNC paths like:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; \\hostnameA\folder\subfolder\file.csv&lt;BR /&gt;I need to &lt;STRONG&gt;batch update all these paths&lt;/STRONG&gt; to:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; \\hostnameB\folder\subfolder\file.csv&lt;/P&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":magnifying_glass_tilted_left:"&gt;🔍&lt;/span&gt; What I've tried:&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;I used the Report Server REST API (/PowerBIReports(id)/DataSources) to list and patch the data sources.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;For embedded .pbix reports, I can retrieve the ConnectionString, but fields like Name, Path, and DataSourceType are null.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;When I try to send a PATCH request with updated connection strings, I get: 「400 Bad Request」&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":question_mark:"&gt;❓&lt;/span&gt;My Questions:&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;P class=""&gt;Is there an &lt;STRONG&gt;official or recommended way to update CSV file paths in deployed .pbix reports in bulk&lt;/STRONG&gt;?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Is it possible to do this &lt;STRONG&gt;without manually opening each .pbix in Power BI Desktop and re-saving&lt;/STRONG&gt;?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Would converting the embedded data sources to &lt;STRONG&gt;shared data sources (.rsds)&lt;/STRONG&gt; help with future automation?&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P class=""&gt;Thanks in advance for any advice or workaround!&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;PowerShell Script&lt;/P&gt;&lt;P&gt;#script&lt;/P&gt;&lt;P&gt;$server = "&lt;A href="http://hostname" target="_blank"&gt;http://hostname&lt;/A&gt;" # Do not include /reports&lt;BR /&gt;$apiBase = "$server/reports/api/v2.0"&lt;BR /&gt;$oldHost = "\\hostnameA"&lt;BR /&gt;$newHost = "\\hostnameB"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Get all Power BI reports&lt;BR /&gt;$reports = Invoke-RestMethod -Uri "$apiBase/PowerBIReports" -UseDefaultCredentials&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;foreach ($report in $reports.value) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $reportId = $report.Id&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $reportName = $report.Name&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; # Get data sources for the report&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $dataSourcesUrl = "$apiBase/PowerBIReports($reportId)/DataSources"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $dataSources = Invoke-RestMethod -Uri $dataSourcesUrl -UseDefaultCredentials&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; $updateNeeded = $false&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $updateDetails = @()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; foreach ($ds in $dataSources.value) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $oldConnStr = $ds.ConnectionString&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Check if old hostname is present&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($oldConnStr -like "*$oldHost*") {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $newConnStr = $oldConnStr -replace [regex]::Escape($oldHost), $newHost&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "`n[$reportName] Updating connection string:" -ForegroundColor Cyan&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "Original: $oldConnStr"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "Updated : $newConnStr" -ForegroundColor Yellow&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Prepare updated datasource object&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $updateDetails += @{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataSourceType = $ds.DataSourceType&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ConnectionString = $newConnStr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name = $ds.Name&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Path = $ds.Path&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $updateNeeded = $true&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if ($updateNeeded) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $body = @{ value = $updateDetails } | ConvertTo-Json -Depth 10&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # Send PATCH request to update the data source&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $patchUrl = "$apiBase/PowerBIReports($reportId)/DataSources"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Invoke-RestMethod -Method Patch -Uri $patchUrl -UseDefaultCredentials -Body $body -ContentType "application/json"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Write-Host "✔ Data sources updated for report [$reportName]" -ForegroundColor Green&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 08:35:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4681556#M40569</guid>
      <dc:creator>A111462</dc:creator>
      <dc:date>2025-05-06T08:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to batch update CSV data source paths in deployed Power BI Report Server .pbix files?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4681755#M40578</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="909566" data-lia-user-login="A111462" class="lia-mention lia-mention-user"&gt;A111462&lt;/a&gt;&amp;nbsp;, Thank you for reaching out to the Microsoft Community Forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no official method to update paths, as the REST API cannot modify embedded data sources. The recommended workaround is to use the PowerShell script &lt;A href="https://learn.microsoft.com/en-us/power-bi/report-server/rest-api" target="_blank"&gt;Develop with the REST APIs for Power BI Report Server&lt;/A&gt; to download .pbix files, update their Connections file and re-upload them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, it is possible without manual edits. The script automates updates by editing .pbix files’ internal JSON, eliminating the need to open each in Power BI Desktop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, converting to shared data sources (.rsds) simplifies future updates by centralizing path management. Create .rsds and update reports to reference them, enabling REST API changes. Plan this migration after the immediate update. &lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/sql/reporting-services/report-data/create-modify-and-delete-shared-data-sources-ssrs?view=sql-server-ver16" target="_blank"&gt;Create, Modify, and Delete Shared Data Sources (SSRS)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example PowerShell script:&lt;/P&gt;
&lt;P&gt;$server = "&lt;A href="http://hostname" target="_blank"&gt;http://hostname&lt;/A&gt;"&lt;/P&gt;
&lt;P&gt;$apiBase = "$server/reports/api/v2.0"&lt;/P&gt;
&lt;P&gt;$oldHost = "\\hostnameA"&lt;/P&gt;
&lt;P&gt;$newHost = "\\hostnameB"&lt;/P&gt;
&lt;P&gt;$tempFolder = "C:\Temp\PBIX_Processing"&lt;/P&gt;
&lt;P&gt;$logFile = "C:\Temp\PBIX_Update_Log.txt"&lt;/P&gt;
&lt;P&gt;$backupFolder = "C:\Temp\PBIX_Backups"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function Write-Log {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; param($Message, $Color = "White")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "$timestamp - $Message" | Out-File -FilePath $logFile -Append&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Host "$timestamp - $Message" -ForegroundColor $Color&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if (-not (Test-Path $tempFolder)) { New-Item -ItemType Directory -Path $tempFolder | Out-Null }&lt;/P&gt;
&lt;P&gt;if (-not (Test-Path $backupFolder)) { New-Item -ItemType Directory -Path $backupFolder | Out-Null }&lt;/P&gt;
&lt;P&gt;Write-Log "Starting .pbix update process" "Green"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $reports = (Invoke-RestMethod -Uri "$apiBase/PowerBIReports" -UseDefaultCredentials).value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Retrieved $($reports.Count) reports"&lt;/P&gt;
&lt;P&gt;} catch {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Error retrieving reports: $_" "Red"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;foreach ($report in $reports) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $reportId = $report.Id&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $reportName = $report.Name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Processing report: $reportName" "Cyan"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $backupPath = Join-Path $backupFolder "$reportName`_$(Get-Date -Format 'yyyyMMdd_HHmmss').pbix"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $pbixPath = Join-Path $tempFolder "$reportName.pbix"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $downloadUrl = "$apiBase/PowerBIReports($reportId)/Content/`$value"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Invoke-RestMethod -Uri $downloadUrl -UseDefaultCredentials -OutFile $pbixPath&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Copy-Item -Path $pbixPath -Destination $backupPath&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Backed up $reportName to $backupPath"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $extractPath = Join-Path $tempFolder "$reportName"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expand-Archive -Path $pbixPath -DestinationPath $extractPath -Force&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $connectionsFile = Join-Path $extractPath "Connections"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Test-Path $connectionsFile) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $connections = Get-Content $connectionsFile | ConvertFrom-Json&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $updated = $false&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach ($conn in $connections.Connections) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($conn.ConnectionString -like "*$oldHost*") {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $newConnStr = $conn.ConnectionString -replace [regex]::Escape($oldHost), $newHost&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Updating: $($conn.ConnectionString) -&amp;gt; $newConnStr" "Yellow"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $conn.ConnectionString = $newConnStr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $updated = $true&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($updated) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $connections | ConvertTo-Json -Depth 10 | Set-Content $connectionsFile&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $newPbixPath = Join-Path $tempFolder "$reportName`_updated.pbix"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Compress-Archive -Path "$extractPath\*" -DestinationPath $newPbixPath -Force&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $uploadUrl = "$apiBase/PowerBIReports($reportId)/Content"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $headers = @{ "Content-Type" = "application/octet-stream" }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $pbixContent = [System.IO.File]::ReadAllBytes($newPbixPath)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Invoke-RestMethod -Method Put -Uri $uploadUrl -UseDefaultCredentials -Headers $headers -Body $pbixContent&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "✔ Report [$reportName] updated and uploaded" "Green"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "No changes needed for [$reportName]" "Gray"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Connections file not found for [$reportName]" "Red"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Error processing [$reportName]: $_" "Red"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } finally {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remove-Item -Path $pbixPath, $extractPath, $newPbixPath -Recurse -Force -ErrorAction SilentlyContinue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;Write-Log "Processing complete!" "Green"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this helped solve the issue, please consider marking it&amp;nbsp;&lt;STRONG&gt;'Accept as Solution'&lt;/STRONG&gt; so others with similar queries may find it more easily. If not, please share the details, always happy to help.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 10:41:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4681755#M40578</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-05-06T10:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to batch update CSV data source paths in deployed Power BI Report Server .pbix files?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4682839#M40589</link>
      <description>&lt;P&gt;Thank you for your response. I ran the sample script you provided, but when executing the following line:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;Expand-Archive -Path $pbixPath -DestinationPath $extractPath -Force&lt;BR /&gt;I encountered an error indicating that .pbix is not a supported archive format. I worked around this by modifying the script as follows:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;$zipPath = Join-Path $tempFolder "$reportName.zip"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Copy-Item -Path $pbixPath -Destination $zipPath -Force&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force&lt;/P&gt;&lt;P class=""&gt;This allowed the file to be extracted successfully. However, there was no file named &lt;STRONG&gt;"Connections"&lt;/STRONG&gt; in the extracted folder. Every report processed resulted in the log message: Connections file not found for [$reportName].&lt;/P&gt;&lt;P class=""&gt;I checked the other extracted files that the connection information might be embedded within the "DataModel" file, but I haven’t been able to open it.&lt;/P&gt;&lt;P class=""&gt;Additionally, I’d like to ask: is there a way to use the API to submit connection string credentials (e.g., username and password) when updating data sources?&lt;/P&gt;&lt;P class=""&gt;Thanks again for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 08:51:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4682839#M40589</guid>
      <dc:creator>A111462</dc:creator>
      <dc:date>2025-05-07T08:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to batch update CSV data source paths in deployed Power BI Report Server .pbix files?</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4682977#M40594</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="909566" data-lia-user-login="A111462" class="lia-mention lia-mention-user"&gt;A111462&lt;/a&gt;&amp;nbsp;, Thank you for reaching out to the Microsoft Community Forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason you're running into trouble with the REST API is that it doesn't support editing embedded data sources within .pbix files. Those connections are stored in a binary format inside a file called DataMashup (not DataModel and there’s no "Connections" file), which isn’t exposed through the API. So, any attempt to use /PowerBIReports(id)/DataSources on embedded sources results in a 400 error, this is expected behaviour. This limitation is documented by Microsoft and unfortunately doesn’t have a workaround using built-in tools alone.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To solve this, you can use Tabular Editor, a lightweight, scriptable and supported tool in the Power BI ecosystem, to batch-edit M queries inside your .pbix files. With a small PowerShell script and a Tabular Editor command, you can programmatically open each report, search for old UNC paths in the query definitions, and replace them with the new path. This avoids the need to automate the Power BI Desktop UI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once that update is complete, you should consider migrating your reports to use shared data sources, called .rsds files in Report Server. These allow connection strings and credentials to be managed independently of the report files. That means that if paths or credentials change again in the future, you can update a single .rsds file, via the web portal or the API, without touching hundreds of .pbix files again. This is the most sustainable way to manage data source connections at scale.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, regarding credentials for embedded data sources, credentials cannot be set via the REST API. They're stored within the .pbix and must be configured in Power BI Desktop. However, .rsds files do support credential submission via the API, including Windows credentials or stored usernames/passwords. This is another reason why migrating to shared data sources is highly recommended for enterprise environments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this helped solve the issue, please consider marking it&amp;nbsp;&lt;STRONG&gt;'Accept as Solution'&lt;/STRONG&gt; so others with similar queries may find it more easily. If not, please share the details, always happy to help.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 07 May 2025 10:14:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/How-to-batch-update-CSV-data-source-paths-in-deployed-Power-BI/m-p/4682977#M40594</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-05-07T10:14:10Z</dc:date>
    </item>
  </channel>
</rss>

