SSRS report powershell script

  • I have SSRS 2008R2 reporting having 3 data sources.

    Say reportname = \Marketing\Test.rdl

    DataSource name = \Shared DataSources\Data1 , 2 ,3

    Now when deploy the report using reports manager upload functionality , after deployment it looses all three connection reference.

    is there any powershell script to set again correct datasource for this 1 report.

  • Can anyone tell what's missing in this?


    $reportServerName = "SSRS01"

    $currentPath ="/Marketing/test1"

    $reportServerUri = "http://{0}/ReportServer/ReportService2010.asmx" -f $reportServerName

    $proxy = New-WebServiceProxy -Uri $reportServerUri -Namespace SSRS.ReportingService2010 -UseDefaultCredential

    $type =$proxy.GetType().Namespace

    $dataSourceArrayType = ($type + '.DataSource[]')

    $dataSourceType = ($type +'.DataSource')

    $numDataSources = 3

    $dataSourceArray = New-Object ($dataSourceArrayType)$numDataSources

    $dataSourceArray[0] = New-Object ($dataSourceType)

    $dataSourceArray[0].Name = "Marketing1"

    $dataSourceArray[0].Item = New-Object ($dataSourceReferenceType)

    $dataSourceArray[0].Item.Reference = "/Shared Data Sources/Marketing1"

    $dataSourceArray[1] = New-Object ($dataSourceType)

    $dataSourceArray[1].Name = "Marketing2"

    $dataSourceArray[1].Item = New-Object ($dataSourceReferenceType)

    $dataSourceArray[1].Item.Reference = "/Shared Data Sources/Marketing2"

    $dataSourceArray[2] = New-Object ($dataSourceType)

    $dataSourceArray[2].Name = "Marketing3"

    $dataSourceArray[2].Item = New-Object ($dataSourceReferenceType)

    $dataSourceArray[2].Item.Reference = "/Shared Data Sources/Marketing3"

    $proxy.setItemDataSources ($currentPath,$DataSourceArray)

  • For one, you do not define $dataSourceReferenceType:

    $dataSourceReferenceType=New-Object "$ns.DataSourceReference"

    What's the output?


Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply