PowerShell script

<< Click to Display Table of Contents >>

Navigation:  Actions > Script tools >

PowerShell script

Powershell is a powerful scripting and command-line tool for managing your system. You can find more information about the PowerShell script language and the commands description here.

You can use the built-in RoboTaskApp COM object to communicate with RoboTask. For example:


$rt = New-object -ComObject RoboTask.App

write-host RoboTask version: $rt.version

write-host RoboTask object members

$rt | Get-Member


For a PowerShell script, the current ThreadId of the task is passed through the ROBOTASK_SCRIPT_ID environment variable.

Example of the script:


$rt = New-object -ComObject RoboTask.App

#write-host $env:ROBOTASK_SCRIPT_ID






Toolbar buttons

Save and Exit - saves task settings and closes the editor

Cancel - closes the editor without saving

Open - opens the script text from the external text file and places it into the script text editor.

Save as - saves the script text to an external file.

Add var - calls the variable selection window and places the variable call at the current cursor position.


Script Mode

There are two options

Execute inline script - execute the script you have written in the script editor. In this case, you will see the text editor.

Execute external script - run the script from an external file.


Expand variables

Check this box if you want to expand RoboTask variables in the script body before running the script. With variables, you can create dynamic text depending on different conditions.



In "Execute inline script" mode, it is a script text editor.

In "Execute External script" mode, it is a field to enter the file name and a file selection button.






Assign exit code to a variable

Enter the variable name to save the script exit code. By default, the exit code is 0, but it can be changed in the script.


Assign script output to a variable

Enter a variable name in this field to write the script's output text stream to a variable. You will then be able to process this text in your task.



Path to PowerShell - empty by default. This means tan you use system default PowerShell utility. But you can use alternate PowerShell and specify path to it. (for example PWSH.EXE)


Command line template

A command line template is needed to be able to pass custom parameters to the script. The template must contain two mandatory predefined parameters:

[InterpreterPath] - path to the interpreter module to be executed

[ScriptPath] - path to the script file

Both parameters are formed automatically.


Module search paths

Here you can set the search paths to additional cmdlets, script files, or operable program.



note Related Topics

Python Script

RoboTask object for Python

JavaScript/Node.js script

RoboTask object for node.js

PowerShell script

JS script

JS Evaluate

VB Script

VB Evaluate

RoboTaskApp object