Last active
November 28, 2023 10:31
-
-
Save EitanBlumin/e3b34d4c2de793054854e0e3d43f4349 to your computer and use it in GitHub Desktop.
Powershell script to deploy SSRS reports from a folder (all rds and rdl files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string] $SourceFolder = "SSRS", | |
[string] $TargetReportServerUri = "http://localhost/ReportServer", | |
[string] $TargetFolder = "MyReports" | |
) | |
$ErrorActionPreference = "Stop" | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck | |
if ($SourceFolder -eq "") { | |
$SourceFolder = $(Get-Location).Path + "\" | |
} | |
if (!$SourceFolder.EndsWith("\")) | |
{ | |
$SourceFolder = $SourceFolder + "\" | |
} | |
Write-Output "=====================================================================================" | |
Write-Output " Deploying SSRS Reports" | |
Write-Output "Source Folder: $SourceFolder" | |
Write-Output "Target Server: $TargetReportServerUri" | |
Write-Output "Target Folder: $TargetFolder" | |
Write-Output "=====================================================================================" | |
Write-Output "Marking PSGallery as Trusted..." | |
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted | |
Write-Output "Installing ReportingServicesTools Module..." | |
Install-Module -Name ReportingServicesTools | |
Write-Output "Requesting RSTools..." | |
Invoke-Expression (Invoke-WebRequest https://aka.ms/rstools) | |
#Get-Command -Module ReportingServicesTools | |
Write-Output "Creating Folder: $TargetFolder" | |
New-RsFolder -ReportServerUri $TargetReportServerUri -Path / -Name $TargetFolder -Verbose -ErrorAction SilentlyContinue | |
$TargetFolder = "/" + $TargetFolder | |
Write-Output "Deploying Data Source files from: $SourceFolder" | |
DIR $SourceFolder -Filter *.rds | % { $_.FullName } | | |
Write-RsCatalogItem -ReportServerUri $TargetReportServerUri -Destination $TargetFolder -Verbose -Overwrite | |
Write-Output "Deploying Data Set files from: $SourceFolder" | |
DIR $SourceFolder -Filter *.rsd | % { $_.FullName } | | |
Write-RsCatalogItem -ReportServerUri $TargetReportServerUri -Destination $TargetFolder -Verbose -Overwrite | |
Write-Output "Deploying Report Definition files from: $SourceFolder" | |
DIR $SourceFolder -Filter *.rdl | % { $_.FullName } | | |
Write-RsCatalogItem -ReportServerUri $TargetReportServerUri -Destination $TargetFolder -Verbose -Overwrite |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment