Following code has been tested on SSRS 2010 to 2016
- Install the Reporting Service Powershell Module
Install-Module -Name ReportingServicesTools
2. Code to download RDLs
# ##########################
# Download RDLs from SSRS
# Author: Kevin C. L.
############################
# Parameters definition
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$ServerName,
[Parameter(Mandatory=$False,Position=2)]
[string]$Destination
)
$errorCode=0
if($Destination -eq "" -or $Destination -eq $null){$Destination=".\"} # Using current folder as download destination
$ssrsUrl = "http://$($ServerName)/ReportServer/ReportService2010.asmx?wsdl"
# Try initialze SSRS WebProxy client to the reporting server
try{
$ssrsProxy = New-RsWebServiceProxy -ReportServerUri $ssrsUrl
}catch{
$errorCode = 1
$exception = $_.Exception
}finally{
if($errorCode -ne 0){
Write-Host -ForegroundColor "red" "Failed to connect to $($Server)"
Write-Host "Exception: $($exception.message)"
}else{
Write-Host "Successfully connected to SSRS service on $($ServerName)!"
# Start downloading SSRS Report files from reporting server
Write-Host "Start downloading Report files!"
try{
Out-RsFolderContent -Proxy $ssrsProxy -RsFolder "/" -Destination $Destination -Recurse
}catch{
$errorCode = 2
$exception = $_.Exception
}finally{
if($errorCode -eq 0){
Write-Host "All Reporting files have been downloaded from $($ServerName)!"
}else{
Write-Host -ForegroundColor "red" "Failed to download reporting files from $($Server)"
Write-Host "Exception: $($exception.message)"
}
}
}
}
exit $errorCode