# Powershell payload

**URL:** <https://discourse.nodered.org/t/powershell-payload/19613>\
**Category:** General\
**Created:** [26 December 2019 22:43 UTC](https://discourse.nodered.org/t/powershell-payload/19613 "2019-12-26T22:43:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![KevinPamu](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@KevinPamu](https://discourse.nodered.org/u/KevinPamu)\
**Post date:** [26 December 2019 22:43 UTC](https://discourse.nodered.org/t/powershell-payload/19613/1 "2019-12-26T22:43:37Z")

</div>

Hello,

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

```auto
https://flows.nodered.org/node/node-red-contrib-powershell

```

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.

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![WalterWhite](https://avatars.discourse-cdn.com/v4/letter/w/7ea924/32.png) [@WalterWhite](https://discourse.nodered.org/u/WalterWhite)\
**Post date:** [27 January 2020 21:15 UTC](https://discourse.nodered.org/t/powershell-payload/19613/2 "2020-01-27T21:15:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [27 January 2020 21:26 UTC](https://discourse.nodered.org/t/powershell-payload/19613/3 "2020-01-27T21:26:19Z")

</div>

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:

```auto
this.on('input', function(msg) {
            ps.addCommand(msg.payload);
            ps.invoke()
            .then(output => {
                msg.payload = output;
                this.send([output, null]);
            })
            .catch(error => {
                msg.payload = error;
                this.error(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.

---

<div class="post-metadata">

**Author:** ![WalterWhite](https://avatars.discourse-cdn.com/v4/letter/w/7ea924/32.png) [@WalterWhite](https://discourse.nodered.org/u/WalterWhite)\
**Post date:** [27 January 2020 22:01 UTC](https://discourse.nodered.org/t/powershell-payload/19613/4 "2020-01-27T22:01:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KevinPamu](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@KevinPamu](https://discourse.nodered.org/u/KevinPamu)\
**Post date:** [27 January 2020 22:14 UTC](https://discourse.nodered.org/t/powershell-payload/19613/5 "2020-01-27T22:14:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 February 2020 22:14 UTC](https://discourse.nodered.org/t/powershell-payload/19613/6 "2020-02-10T22:14:33Z")

</div>

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