2
votes

Apologies here as this is my first stackoverflow question.

What I'm trying to do is edit the location of a shared dataset within an RDL. That is to say, I'm using powershell to deploy reports to a report server from my local hard drive. Unfortunately, some of these reports use shared datasets, and the location that the RDL references is different than the actual location of the shared datasets. The shared dataset name are the same though.

So, is there a way that when I'm uploading these reports, that I can loop through them and change the shared dataset reference, so that it points to the actual location? For example, right now the RDL references a shared dataset as "Employee", but I would like to, using powershell, change it to /IT/Sales/Datasets/Employee. Thank you very much in advance.

1

1 Answers

0
votes

You can use use the ReportingService2010 web service for this, which you can create using New-WebServiceProxy. Beware the -Namespace parameter, because you'll need to instantiate other objects and will run into this problem.

The gist of it is:

$dataSources = $proxy.GetItemDataSources("/path/to/report")
$dsRef = New-Object -TypeName ($proxy.GetType().Namespace + ".DataSourceReference")
$dsRef.Reference = "/path/to/datasource"
$dataSources[0].Item = $dsRef
$proxy.SetItemDataSources("/path/to/report", $datasources)

You'll probably want to provide a mapping from data source names to server paths and then lookup the reference based on $dataSources[0].Name. Alternatively, you can interrogate the report XML to find the data sources being used and construct a new DataSource object rather than query the existing ones.

I've assumed SSRS 2008 R2 or higher - if this is for 2005 you'll need to adapt it to use the ReportingService2005 web service.