Error in Downloading Report from Local SSRS Server

  • I am executing this attached code "SampleScript.ps1" to access my SSRS report in my local server and download the report in pdf format in local drive.

    The error which I am getting is as follows,

    Exception calling "SetParameters" with "1" argument(s): "The attempt to connect to the report server failed. Check

    your connection information and that the report server is a compatible version."

    At D:\SalesReport\SampleScript.ps1:61 char:1

    + $rv.ServerReport.SetParameters($params)

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : MissingEndpointException

    Exception calling "Render" with "7" argument(s): "The attempt to connect to the report server failed. Check your

    connection information and that the report server is a compatible version."

    At D:\SalesReport\SampleScript.ps1:79 char:1

    + $bytes = $rv.ServerReport.Render("PDF",

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : MissingEndpointException

    Exception calling "Write" with "3" argument(s): "Buffer cannot be null.

    Parameter name: array"

    At D:\SalesReport\SampleScript.ps1:92 char:1

    + $fileStream.Write($bytes, 0, $bytes.Length)

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ArgumentNullException

    Can any one please help me in this. Following is the version that I am using,

    Powershell: 4.0

    SQLServer: 2014

    Thanks in Advance !

  • The clue(s) are in the error message(s) - the connection string is invalid.

    Concatenate the generated strings and copy/paste into a browser or reverse engineer the URL from the desired report.

    From memory, the report viewer uses its own object:

    powershell

    Add-Type -AssemblyName "Microsoft.ReportViewer.WinForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=xyzabc"

    ```

    powerhshell

    $rv = New-Object Microsoft.Reporting.WinForms.ReportViewer

    Take a look here:

    https://blogs.msdn.microsoft.com/cdndevs/2015/10/14/automate-ssrs-report-generation-using-powershell/

    :w00t:

    gsc_dba

  • Additionally, the example that gsc_dba has is accessing the ReportServer URL, not the Report Manager URL where the path in OPs message is trying via the Report Manager URL. Maybe change the path to use the ReportServer Web Service URL and try again?

    Joie Andrew
    "Since 1982"

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

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