SSRS Reporting Service URL commands

When you would like to access Report Server from your application or just link reports, you can use URL of Report Server for such a task. URL access to Reporting Services supports few useful commands you can handle visualisation your reports.

There are following sets of commands you can change look your Reporting Services.

Find more info here: https://bit.ly/2SYlgr0 .

Find few examples bellow.

Hide Toolbar with parameters.
http://dwh/Reportserver?/Blog/ReportSales7 - Interactive sorting&rc:Parameters=Collapsed
Collapsed toolbar
Picture 1 – Collapsed toolbar
Go to second page.
http://dwh/Reportserver?/Blog/ReportSales0 - Detail data&rc:Section=2
Report second page
Picture 2 – Report second page
List reports in directory.
http://dwh/Reportserver?/Blog/&rs:Command=GetChildren
List directory
Picture 3 – List directory
Get PDF format of report.
http://dwh/Reportserver?/Blog/ReportSales0 - Detail data&rs:Format=PDF
Export report
Picture 4 – Export report

Connect to Reporting Services with PowerShell

In this post I will show you how to make connection to Reporting Web Service Endpoint trough PowerShell. Report Web Service contains following endpoints you can work with:

  • management endpoints
  • execution endpoints
  • SharePoint Endpoints

You can find more info on Microsoft Website https://bit.ly/2LmkNhg. In my post series I will use management endpoint ReportService2005.asmx. There is ReportingService2006.asmx which is designed for developers working in SharePoint mode and ReportingService2010.asmx designed for either SharePoint or native mode.

Goal

List Reporting Services respository through PowerShell commands.

Prerequisites

There are no extra prerequisites since PowerShell is part of .NET framework installed on most of Windows platforms by default. In case you would like update your PowerShell framework go to MSDN https://bit.ly/2xX3F92

For listing Reporting Services repository, we need two rows of commands put to your PowerShell console.

$proxy = New-WebServiceProxy "http://<yourservername>/Reportserver/ReportService2005.asmx" -Namespace SSRS.ReportingService2005 -UseDefaultCredential
$proxy.ListChildren("/blog",$true)
  • The first command uses new-webserviceProxy cmdlet returning Web service proxy object. It allows us to use all proxy methods, SSRS methods in our scenario.
  • In the second command we use to call Web service methods, List Children in our case

After putting these two commands to PowerShell console you will see list of Reporting Services repository items as output in PowerShell console.

You can write easily PowerShell script, to make the solution reusable and configurable like the example bellow.  PowerShell is powerful and fast tool for writing scripts that help you automatize your tasks and you do not need to be an experienced developer. Enjoy

Let’s put basic setup to configuration xml file.

<Configuration>
<SSRSSoap>
<Address>http://Server/ReportServer//reportservice2005.asmx
</Address>
<Credentials UserName="">DefaultCredential</Credentials>
</SSRSSoap>
</Configuration>

Script with function to get data from configuration file and function to connect to SSRS Web Service.

function SSRS-Get-Config-Data ($ConfigPath){
[xml] $xml|out-null 
try {
 $xml= [xml](Get-Content $ConfigPath)
    }
catch {
  Write-Host "Cannot read file" $Error[0]
}
[string] $address|out-null
[string] $credentials|out-null
[string] $credentialName |out-null
try {
    $address= (Select-Xml '//Configuration/SSRSSoap/Address' $xml).node.innertext
    $credentials= (Select-Xml '//Configuration/SSRSSoap/Credentials' $xml).node.innertext
    $credentialName=( Select-Xml '//Configuration/SSRSSoap/Credentials' $xml).node.UserName #.node.Attributes[0].Value
}
catch {
 Write-Host "Wrong file format" $Error[0]
}
$proxy|out-null
try {
if ($credentials -eq "DefaultCredential" )
{
 $proxy = New-WebServiceProxy -Uri $address -Namespace  SSRS.ReportingService2005 -UseDefaultCredential;
}
if ($credentials -eq "Credential" ) {
    $proxy = New-WebServiceProxy -Uri $address -Namespace  SSRS.ReportingService2005 -Credential $credentialName;
}
}
catch
{
Write-Host "Cannot connect to web service" $Error[0]
}
return ,$proxy;

}

function ConnectToWebService ($ConfigPath)
{
$proxy = SSRS-Get-Config-Data $ConfigPath
if ($proxy.GetType().Name -eq "ReportingService2005" ) # check for type
{
 return $proxy
}
}

Example

$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
. $scriptDir\function.ps1

$proxy = ConnectToWebService ".\config.xml"
$proxy.ListsChildren("/",$true)

example_powershell_connect

Automate Reporting Services tasks

Sooner or later, you meet a need to automate some tasks connected with Reporting Services management, for example:

  • Deploy set of reports to Report Server
  • Deleting multiple reports
  • Moving multiple reports
  • Downloading multiple reports from report server
  • Make mass changes in reports
  • Etc.

Fortunately, Reporting Services contains Web Service Endpoints which can be used for handling such a task. You can write C# applications to realise such a solution. Or simply PowerShell to connect to Reporting Web Service and call its methods. Here I come with few posts describing how easy is it to automate your work with Reporting Services with PowerShell. Stay tuned.