The Script action allows you to place custom code into the list of actions, this code can read and set any of the variables associated with the document and create new ones.

A minimal PowerShell script would just be a value that gets echoed to the log, for instance:

"Hello World"

will send the text Hello World to the log.

Use the $context object to create and access variables for use in other actions, for example to replace spaces with underscores in the DocumentName variable:

$name = $context.GetValue("DocumentName")
$name = $name.Replace(" ", "_")
$context.SetValue("DocumentName", $name)

Any variables you set using $context.SetValue are available in templates in subsequent actions. If the variable exists further up the scope then it is set there, otherwise it is set locally and will only be available within the current Action List. If you want to force the variable to be local and override a variable with the same name further up the scope then use:

$context.SetLocalValue("Document Name", "Temporary Document Name")

Access to the raw print stream ia available from the _stream variable. An example of reading and modifying this is available here.

This action replaces the now obsolete Script action, any Script actions with the language set to PowerShell are automatically converted to PowerShell actions.