Powershell payload


I am running the powershell script on a windows machine using the powershell node.


I get a payload that comes back when I change the debug node to msg object but nothing when I just look for the payload.

[{"id":"24bd1866.c47148","type":"inject","z":"811a5a5b.6edda8","name":"","topic":"","payload":"(Get-Item \\\\5553p-loc1\\storeman\\L_SMS.exe).VersionInfo.FileVersion","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":980,"wires":[["b060b702.4cf548"]]},{"id":"b060b702.4cf548","type":"powershell","z":"811a5a5b.6edda8","name":"","x":490,"y":980,"wires":[["9fa9f593.9b2b38","1cf8e6a2.cf0629"],[]]},{"id":"1cf8e6a2.cf0629","type":"debug","z":"811a5a5b.6edda8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","x":720,"y":980,"wires":[]},{"id":"9fa9f593.9b2b38","type":"debug","z":"811a5a5b.6edda8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","x":650,"y":1060,"wires":[]}]

how can I get the output to a msg.payload?

Thanks in advance.

I'm having the same problem and have exhausted every know resource to find the answer. I bet it is something so simple too.

Can you post the output that comes out with full message object? The node you’re using might simply output to a different, (incorrect) property instead making it incompatible with other logical parts of the flow.

Edit: I just took a quick look at the code. It does set it to msg.payload. However, the description says that the first output is for stdout, and the second output for stderr. The code however will never send a message to that second output:

this.on('input', function(msg) {
            .then(output => {
                msg.payload = output;
                this.send([output, null]);
            .catch(error => {
                msg.payload = error;

And if you look closely it is making another mistake. Rather than sending back a message object, it's sending the output/payload. This is a bug in the node, and not a problem caused by either of you.

The node does not have a repository or bugtracker listed. I got the code by doing an npm install and going through it myself. You can try fixing it manually by replacing the following part:
In node_modules\node-red-contrib-powershell\powershell.js, replace this.send([output, null]); by this.send([msg, null]); and a couple lines later this.error(error); by this.error(msg); and see if that fixes this issue.

Edit 2: I got contact details for the author of the node through NPM. Just emailed them with a link to this topic with additional information.


You have just made me the happiest man in the building!!! this solution worked perfectly! Thank you so much.

I will try the suggested solution and give you an update soon. Thanks for the input @afelix .

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.