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:
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:
Any variables you set using $context.SetValue are available in templates in subsequent actions.
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.