☰  TOPICS

Running a PowerShell script

Note: PowerShell scripting is not supported in the Web app. See the compatibility table for a full comparison.

See also:
Overview of scripting in Email Parser
Running a command under the Windows command prompt
Running an external program

Email Parser can run PowerShell scripts as part of your email processing workflow. PowerShell is a powerful scripting language built into Windows that gives you access to a wide range of system features, file operations, and automation capabilities. If you need to perform tasks that go beyond the built-in actions in Email Parser, a PowerShell script action is a great way to extend your workflow.

Setting up a PowerShell script action

To run a PowerShell script, you need to create a new action in the workflow diagram (on the left side of the application) and then choose Run PowerShell script as the type of action.

Choosing Run PowerShell script as the action type in Email Parser

Once you select this action type, a text editor area will appear where you can write or paste your PowerShell script.

Editing a PowerShell script inside Email Parser

While you can type your script directly in Email Parser, keep in mind that Email Parser is not a full-featured code editor. For anything beyond simple scripts, it is a good idea to write and test your PowerShell code in a dedicated editor first, and then paste the final version back into Email Parser. Some popular editors for PowerShell development are:

  • Visual Studio Code with the PowerShell extension, which provides syntax highlighting, debugging, and an integrated terminal.
  • Windows PowerShell ISE (Integrated Scripting Environment), which is already included with Windows and designed specifically for writing and testing PowerShell scripts.
  • JetBrains Rider or other JetBrains IDEs with PowerShell plugin support.

The recommended workflow is to develop and test your script in one of these editors until it works as expected, and then copy it into Email Parser.

Reading and creating fields

PowerShell scripts in Email Parser can interact with the email processing workflow by reading existing fields and creating new ones. This is done through the fields object, which is automatically available inside your script.

You can read any field that has been captured or generated earlier in the workflow. For example, you can access the email sender address, the subject, or any field that a parser has extracted. You can also create new fields by simply assigning a value to a new key in the fields object. These new fields will then be available in subsequent actions of your Email Parser workflow.

Here is an example script that demonstrates both reading existing fields and creating new ones:

# Print all existing Email Parser fields
Write-Output "=== Available fields ==="
foreach ($key in $fields.Keys) {
    $val = $fields[$key]
    if ($val -is [System.Array]) {
        Write-Output "$key = $($val -join ', ')"
    } else {
        Write-Output "$key = $val"
    }
}
Write-Output "========================"

# Create two new fields.
# These fields will be available for the next actions in the Email Parser workflow
$fields["my_custom_field"] = "Hello from PowerShell!"
$fields["processed_timestamp"] = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")

# Copy a file
Copy-Item "C:\Users\myusername\Desktop\report_files.zip" "C:\Users\myusername\Desktop\reports"

As you can see, reading fields is done by accessing $fields["field_name"] and creating new fields is done by assigning a value to a new key, such as $fields["my_custom_field"] = "some value". The fields object acts as a dictionary that is shared between the script and the rest of the Email Parser workflow. Any field you add or modify in this object will be available in the next steps of your workflow, just like fields captured by a parser.

Script output and the Activity tab

Your PowerShell script can display messages in the Email Parser Activity tab (the log shown in the first tab of the application). To do this, simply use the Write-Output command, just as you would in a regular Windows terminal. Any text sent through Write-Output will appear in the Activity tab, which is very useful for debugging your scripts and keeping track of what the script is doing during email processing.

PowerShell script output displayed in the Email Parser Activity tab

It is important to note that the Activity tab can only display output. It cannot accept user input. This means your PowerShell scripts cannot be interactive. Commands that ask the user to press a key to continue, type a yes or no answer, or provide any other kind of input will not work. Make sure your scripts run fully unattended, without requiring any interaction.


© 2008-2026 Triple Click Software Ltd.
News & Updates·Service status

Windows App privacy police and terms of use
Web App privacy police and terms of use

This site privacy police and terms of use
PAD file·Old news