Overview
This n8n node allows you to execute arbitrary PowerShell commands directly from your workflow. You can choose between the default Windows PowerShell or PowerShell Core (cross-platform). The node is useful for automating system administration tasks, running scripts, or integrating with local tools and services that expose a command-line interface.
Common scenarios:
- Automating server maintenance or configuration steps.
- Running custom scripts as part of a deployment pipeline.
- Gathering system information or logs for further processing in n8n.
Example:
You could use this node to run Get-Process
and collect process information, or to automate file management tasks on a Windows server.
Properties
Name | Meaning |
---|---|
Choose PowerShell Type | Select which PowerShell executable to use: - PowerShell: Uses the default full PowerShell installation (likely PowerShell 5). - PowerShell Core: Uses PowerShell Core (version 6 or 7, cross-platform). |
Command | The PowerShell command or script to execute. Multi-line input is supported. Example: Write-Output "Hello World" |
Execute Once | If enabled, the command runs only once (using the first input item). If disabled, the command runs separately for each input item. |
Output
The node outputs a JSON object for each execution:
{
"exitCode": 0,
"stderr": "",
"stdout": ""
}
- exitCode: The exit code returned by the PowerShell process.
- stderr: Any error output produced by the command.
- stdout: The standard output produced by the command.
If an error occurs and "Continue On Fail" is enabled, the output will be:
{
"error": "Error message"
}
Dependencies
- Requires access to either
powershell.exe
(Windows PowerShell) orpwsh
(PowerShell Core) on the host machine where n8n is running. - No external API keys are required.
- The n8n instance must have permission to execute shell commands.
Troubleshooting
Common issues:
- Command not found: If the selected PowerShell executable (
powershell.exe
orpwsh
) is not installed or not in the system PATH, the node will fail with an error likespawn powershell.exe ENOENT
.- Resolution: Ensure the chosen PowerShell version is installed and accessible from the command line.
- Permission denied: The n8n process may lack permission to execute shell commands.
- Resolution: Run n8n with appropriate permissions or adjust system policies.
- Script errors: If the provided command contains syntax errors or fails during execution, the error message will appear in the
stderr
field or as anerror
property if "Continue On Fail" is enabled.