Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By : Donabel Santos
Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By: Donabel Santos

Overview of this book

Table of Contents (21 chapters)
SQL Server 2014 with PowerShell v5 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Changing an SSRS report's data source reference


In this recipe, we will update an SSRS report's data source.

Getting ready

In this recipe, we will change the data source of the /Customer Reports/Customer Sales report, which originally uses the data source reference /Data Sources/AdventureWorks2014 to point to /Data Sources/Sample.

Alternatively, pick an existing report in your environment and the data source you want this report to reference. Note the names and path to these items.

How to do it...

Let's take a look at the steps to change an SSRS report's data source:

  1. Open PowerShell ISE as an administrator.

  2. Add the following script and run it:

    $reportServerUri  = "http://localhost/ReportServer/ReportService2010.asmx"
    $proxy = New-WebServiceProxy -Uri $reportServerUri -UseDefaultCredential
    
    #get autogenerated namespace
    $type = $proxy.GetType().Namespace
    
    #specify which report's data source to change
    $reportPath = "/Customer Reports/Customer Sales"
    
    #look for the report in the catalog items array...