Skip to content

Instantly share code, notes, and snippets.

@jklemmack
Created June 12, 2018 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jklemmack/906ba286f807a0b118929423b5325182 to your computer and use it in GitHub Desktop.
Save jklemmack/906ba286f807a0b118929423b5325182 to your computer and use it in GitHub Desktop.
<#
# Run these two lines to download the Microsoft Powershell Tools.
Project URL: https://github.com/Microsoft/ReportingServicesTools
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/Microsoft/ReportingServicesTools/master/Install.ps1)
#>
function Set-RsDataSourceReferenceGlobal {
param (
[string] $ReportServerUri,
[string] $ServerFolder,
[string] $DataSourcePath
)
Write-Host 'Scanning ' $ServerFolder
$serverReports = Get-RsFolderContent -ReportServerUri $ReportServerUri -RsFolder $ServerFolder | ?{$_.TypeName -eq 'Report'} | Select-Object -ExpandProperty Name
$serverReports | %{
$report = $ServerFolder + '/' + $_
$ds = Get-RsItemDataSource -ReportServerUri $ReportServerUri -RsItem $report
Write-Host 'Updating sources in ' $report
$ds | %{ Set-RsDataSourceReference -ReportServerUri $ReportServerUri -Path $report -DataSourceName $_.Name -DataSourcePath $DataSourcePath }
}
<#
$reportsToAdd = $localReports | ?{$serverReports -notcontains $_ }
$reportsToAdd | %{
Write-Host 'Adding report ' $_
$localPath = $LocalFolder + '\' + $_
Write-RsCatalogItem -ReportServerUri $ReportServerUri -Path $localPath -RsFolder $ServerFolder -Overwrite
}
#>
$serverFolders = Get-RsFolderContent -ReportServerUri $ReportServerUri -RsFolder $ServerFolder | ?{$_.TypeName -eq 'Folder'} | Select-Object -Expand Name
foreach ($folder in $serverFolders) {
$f = $ServerFolder + '/' + $folder
Set-RsDataSourceReferenceGlobal -ReportServerUri $ReportServerUri -ServerFolder $f -DataSourcePath $DataSourcePath
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment