SSRS PowerShell deserialize report to XML

Useful script/function to get report definition to XML. You can modify the xml and serialize it back to Report Server – so easy. Go to Connect to Reporting Services with PowerShell, to get script that connect to SSRS Web Service.

Parameters:

  • $proxy – proxy Web Service
  • $path – report path
function DeserializeReportDefinitionToXml($proxy,$path)
 {

[System.Xml.XmlDocument] $rdlFile = New-Object System.Xml.XmlDocument;  
[byte[]] $reportDefinition = $null          ;     
[System.IO.MemoryStream] $memStream              | Out-Null;
$reportDefinition                             | Out-Null;
 try{
    $reportDefinition = $proxy.GetReportDefinition($path);
}

catch{   Write-Host "Get report definition problem " $Error[0]
}
 
try{ 
$memStream = New-Object System.IO.MemoryStream(@(,$reportDefinition));
}
catch{
    Write-Host "Problem saving to memory " $Error[0]
}
 try{
$rdlFile.Load($memStream) ;
}
catch{
    Write-Host "Problem load from memory" $Error[0]
}
return $rdlFile
 }

Let’s try. Write-down hierarchy of groups of your Tablix. Use bellow mentioned function, set proxy and Report path (Report should contain Tablix). Be careful of xml namespace used in function. It depends on version of your Report Server.

function TablixRowHierarchy($proxy,$path){
[System.Xml.XmlDocument] $xml | Out-Null;
$xml=DeserializeReportDefinitionToXml $proxy $path ;
[System.Xml.XmlNamespaceManager] $_nsmgr | Out-Null;
 
try{
  $_nsmgr = $xml.nameTable -as [System.Xml.XmlNamespaceManager];
  $_nsmgr.AddNamespace("a", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");
}
catch{
 Write-Host "problem create namespace" $Error[0]
}
[int] $level1 = 0;
 
foreach ($node in $xml.SelectSingleNode("/a:Report/a:Body/a:ReportItems/a:Tablix/a:TablixRowHierarchy",$_nsmgr).SelectNodes9"//a:TablixMembers",$_nsmgr))
{
 foreach ($val in $node.SelectNodes("a:TablixMember/a:TablixHeader/a:CellContents/a:Textbox/a:Paragraphs/a:Paragraph/a:TextRuns/a:TextRun/a:Value",$_nsmgr))
{
   Write-Host "Node value " + $val.InnerText 
 }
Write-Host "Node name " + $node.Name
}
}

SSRS report Chart

Here I come with post where I create graph that displays results from my testing lab I described in previous post. Reporting Services offers lots of possibilities of data visualisations. Graphs are basic components for scenarios you need to visualise your data.

File -> New -> Project

Project menu
Picture 1 – Project menu

Continue with Business Intelligence -> Reporting Services -> Report Server Project. At the bottom part of New Project window set Project Name and its location.

New project
Picture 2 – New project

New empty Report Server project was created.

Add New Report, right click Reports in Solution Explorer.

Solution Explorer
Picture 3 – Solution Explorer

Go to Toolbox pane and click on Chart component.

Toolbox
Picture 4 – Toolbox

Select Bar Chart type from chart palette.

Chart Type
Picture 5 – Chart Type

New Chart component is added into the Visual Studio design area.

Chart
Picture 6 – Chart

Right click on Chart to get Chart Properties dialog box. Map Chart to its dataset. Select GetData dataset from Dataset name select box.

Chart properties
Picture 7 – Chart properties
Chart properties
Picture 8 – Chart properties

Our goal is to get something similar on picture bellow. We want to get results from our tests. It will be grouped by categories represented by tested counters. Set each scenario to chart series.

Chart
Picture 9 – Chart

When you click on chart component you get Chart Data dialog box on the right side.

  • In Values section select CounterValue, results from our tests.
  • Set CounterName to Category Groups to get testing perspective of our data, counters.
  • TaskOwnerName will be set as Series Groups, scenarios we tested
Chart data
Picture 10 – Chart data

Finally, we got simple chart as on picture bellow.

 Chart
Picture 11 – Chart

Reporting Services Chart is very complex component. I didn’t show all its possibilities it has. In this post I created the simplest one Chart to represented lab data.

SSRS report manager rights

SSRS Report Manager supports Windows authentication by default. There are few other authentication types supported, you can configure. See https://bit.ly/2LYNyRy. If you would like to use another type of authentication you should implement it through Reporting Services extension https://bit.ly/2yBJjmj.

When you would like to manage user access to Reporting Services it is realized by roles you set to its login. There are two areas of roles you set to users.

One is set in Report Manager site settings and its scope is System access and the second one on Report Item level (Reports, Folders, etc.)

In site settings you set roles for users that should have rights to manage Schedules for example.

Below is list of Report Item roles taken directly from MSDN. Roles are inherited to item by default from its container.

https://docs.microsoft.com/en-us/sql/reporting-services/security/role-definitions-predefined-roles?view=sql-server-2017

Content Manager Role Item May manage content in the Report Server. This includes folders, reports, and resources.
Publisher Role Item May publish reports and linked reports to the Report Server.
Browser Role Item May view folders, reports, and subscribe to reports.
Report Builder Role Item May view report definitions.
My Reports Role Item May publish reports and linked reports; manage folders, reports, and resources in a users My Reports folder.
System Administrator Role System View and modify system role assignments, system role definitions, system properties, and shared schedules, in addition to create role definitions, and manage jobs in Management Studio.
System User Role System View system properties, shared schedules, and allow use of Report Builder or other clients that execute report definitions.

Report items, Reports, Path go to Report properties by click on right arrow next to the report, report item or folder name.

Linked report
Picture 1 – Linked report

Go to Security item from the menu.

Security
Picture 2 – Security

In case of folder you can go to Security through Folder Settings from main menu.

Main menu
Picture 3 – Main menu

In Security section you can see users with accessed roles. You can Edit current security settings or add new user by clicking on New Role Assignment.

Domain user
Picture 4 – Domain user

When adding new user add domain\user login and check roles you would like to access to the user.

 Roles
Picture 5 – Roles

When setting System roles go to site settings on the top menu of Report Manger.

Site Settings
Picture 6 – Site Settings

Administration roles

Picture 7 – Administration roles