Skip to content

Run Scripts

dmilov edited this page Dec 8, 2020 · 2 revisions

To run a script in SRS, users request Script Execution. Script Execution is an SRS resource that represents a script that the user requests to run in a Runspace. SRS assigns a unique Id for script execution and lets the user track the script progress and outcomes. When a script execution completes, SRS keeps a script execution record with the produced outputs. Script outputs consist of objects that script returns and messages that are raised in PowerShell run-time streams. PowerShell has six output streams Output, Error, Warning, Information, Debug, and Verbose. Everything produced by command return or Write-Output is recorded in the Output stream.

SRS separates Output and other Streams in different APIs. SRS presents the Output stream as a list of objects produced by the script. There are different formats of serialization for these objects that SRS client can request with the Script Execution request. Text and JSON are currently supported. Text format formats the output objects as a table the same way they are formatted in the PowerShell Console. JSON format carries type information with the class name and interface the class implements, and the object properties. The JSON format is for programmable consumption of the script output. Other streams are collected as records of Message and Time of arrival. The time of arrival is the time when a message comes in the concrete PowerShell runtime stream.

A script in PowerShell can produce output objects and messages in other streams. In PowerShell there are two types of errors, terminating and non-terminating. The terminating errors are exceptions that break the script execution. Non-terminating errors are, errors that are sent to the Error stream but the script is not stopped.

In SRS a Script Execution is considered to complete successfully. If there are no terminating errors. As a result, a script execution can complete successfully, and in the same time, the script can produce errors that are tracked in the Script Execution Error stream.