Download All SSRS .RDL Files using Power Shell Script - Working Script Included

Open PowerShell ISE and copy and paste the code below.

--------------------------

$downloadFolder = "ChooseAnyLocalPathWhereThePowerShellRuns-Like D:\SSRS RDL FILES\"

$ssrsServer = "EnterHereYourReportServerWebServiceURL"

$secpasswd = ConvertTo-SecureString "YourDomainAdminPassword" -AsPlainText -Force

$mycreds = New-Object System.Management.Automation.PSCredential ("YourDomainName\YourDomainAdminUserName", $secpasswd)

 

# SSRS Webserver call

$ssrsProxy = New-WebServiceProxy -Uri "$($ssrsServer)/ReportService2010.asmx?WSDL" -Credential $mycreds

 

# List everything on the Report Server, recursively, but filter to keep Reports and DataSources

$ssrsItems = $ssrsProxy.ListChildren("/", $true) | Where-Object {$_.TypeName -eq "DataSource" -or $_.TypeName -eq "Report"}

 

# Loop through reports and data sources

Foreach($ssrsItem in $ssrsItems)

{

    # Determine extension for Reports and DataSources

    if ($ssrsItem.TypeName -eq "Report")

    {

        $extension = ".rdl"

    }

    else

    {

        $extension = ".rds"

    }

     

    # Write path to screen for debug purposes

    Write-Host "Downloading $($ssrsItem.Path)$($extension)";

 

    # Create download folder if it doesn't exist (concatenate: ""EnterTheSameLocalPathWhich YouEnteredInTheFirstLineOFThisScript-Like D:\SSRS RDL FILES\" and "/SSRSFolder/")

    $downloadFolderSub = $downloadFolder.Trim('\') + $ssrsItem.Path.Replace($ssrsItem.Name,"").Replace("/","\").Trim()

    New-Item -ItemType Directory -Path $downloadFolderSub -Force > $null

 

    # Get SSRS file bytes in a variable

    $ssrsFile = New-Object System.Xml.XmlDocument

    [byte[]] $ssrsDefinition = $null

    $ssrsDefinition = $ssrsProxy.GetItemDefinition($ssrsItem.Path)

 

    # Download the actual bytes

    [System.IO.MemoryStream] $memoryStream = New-Object System.IO.MemoryStream(@(,$ssrsDefinition))

    $ssrsFile.Load($memoryStream)

    $fullDataSourceFileName = $downloadFolderSub + "\" + $ssrsItem.Name +  $extension;

    $ssrsFile.Save($fullDataSourceFileName);

}

-----------------------------