Using PowerShell Run a Report (With Parameters) and Save to Excel or PDF RRS feed

  • Question

  • I actually have a script that does half of this job but results (I think) in the report being displayed in the Report Viewer, in Excel or PDF format, ready to save to a file. I want to go a step further and save the file without actually displaying the report. I THINK this requires streaming the render result to a physical file location but I don't know how to do this in a PowerShell script.

    Any example code would be most welcome.

    R Campbell

    Friday, November 14, 2014 11:43 PM

All replies

  • Is this something like it (assuming that everything before these two lines is correct)? I won't get a chance to test it until Monday.

    $rsExec = new-object ReportExecution2005.ReportExecutionService

    #More code to set parameter values etc

    $render = $rsExec.Render($format, $deviceInfo,[ref] $extention, [ref] $mimeType,[ref] $encoding, [ref] $warnings, [ref] $streamIDs) Get-Process | Out-File -LiteralPath "C:\Test.xls" -InputObject $render

    R Campbell

    Saturday, November 15, 2014 10:14 AM