Execute PowerShell command in function node

Describe the issue/error/question

I am trying to run a PowerShell command in a function node but I am not getting any return values from ‘error’, ‘stdout’ and ‘stderr’. Can you help me with this?

Greetings and thanks in advance
René

What is the error message (if any)?

None

Please share the workflow

Share the output returned by the last node

[
  {
    "error": null,
    "stdout": null,
    "stderr": null
  }
]

Sources

Information on your n8n setup

  • Operating System: Windows 10
  • n8n version: 0.188.0
  • Database you’re using (default: SQLite): default
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: npm

Hey @r297493,

Welcome to the community :cake:

Is the powershell command actually running? It looks like you are running n8n on Windows through npm if your default system shell is set to Powershell the Execute Command node would handle this for you already or there is a community node here: https://www.npmjs.com/package/@starfallprojects/n8n-nodes-powershell

Hello @Jon ,

thanks for the tip. I definitely need the function node for my purposes. Based on the code from starfallprojects/n8n-nodes-powershell I was able to work out a solution. Had not considered that exec runs asynchronously.

Credits to starfallprojects/n8n-nodes-powershell

Here is the working solution:

Regards René

2 Likes