The following example executes a report, saves the output as a CSV file and opens the file in the default CSV document viewer.

  • Connect to the reporting web service

  • Specify the unique identifier of the report to execute in GUID format.

  • Specify the customer or container against which to execute the report, by default this is the root container with identifier 1000.

  • Set the sort order to "Ascending" or "Descending", and the sort column. This has no effect if the report does not support sorting.

  • The user must have permissions to execute this report.



Code Sample


# Executes the report and saves the output as a CSV file in the user's temp directory.

$filename = "$env:TEMP\ReportOutput.csv"

$reportIdentifier = [Guid]"5413a609-80da-490b-ad76-104aa8d4021f";

$parameterValues = $reporting.GET_DefaultReportParameterValues($reportIdentifier);

$output = $reporting.DO_ExecuteReportCsv($reportIdentifier, $parameterValues, 1000, "Ascending", 1)

[IO.File]::WriteAllText($filename, $output)

[System.Diagnostics.Process]::Start($filename

 


For information about setting report parameters see the Execute a Report to PDF example.