Workbench 0.18 User Guide

Guest Tools

Powershell Support

If you have a ps1 script you use a lot (or not) you can add it tool your toolbox and execute it against data objects on the workpad.

Screenshot of Tool Details dialogue

We install the script into the Toolbox in much the same way as we would install EXEs.  When you click on the Path button the Select an application dialogue appears as above.  Note how the File Name extension filter button now offers *.exe and *.ps1.  Simply select the ps1 script file you wish to use as a tool.

Tool Usage Profile

There is a new category of profile arguments for Powershell scripts.  These become available when you check the Script Integration check box.

Script Integration means you are going to set variable values directly into your script , note that there is no Arguments box to set a command string. In integrated mode you’re a mutating the .ps1 file and controlling the script directly.  You set the variable name you want to fill in the [variable] column.

Screenshot of tool profile arguments for Powershell scripts

The script variables are:

  • Argument = inject a Workbench calculated value into your script, you can choose form the combo box that’ll appear
  • String = inject a string into the variable
  • Self = inject the path of the script you’re executing
  • Dir = inject a directory path
  • File = inject a file path
  • Dynamic = inject a value that the user will be asked to provide when the script tool profile is executed
Legacy Method to Pass Variables

You can run your script the old command prompt way if you prefer, just don’t check Script Integrated, below is an example of all you need to supply.

Screenshot of legacy-style tool profile arguments for Powershell scripts

Workbench will handle your script in exactly the same way it handles tools. It will transform the files to make them acceptable to your script input if it can (or has to). It will collect the output from your script and plug it into the Object Explorer. It will run your script as an input list (pushing multiple files in as a delimited list) or execute the script for every file in your selection.