How to run node js script from powershell script and use the output of node js script in powershell script? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to run node js script from powershell script and use the output of node js script in powershell script? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have a node js script that can return a string value. I want to return that value and use it in PowerShell script.

I have done console.log(); to print the output. How to use it in PowerShell script?
The output looks like this:

D:developmentjs-automation>node index.js MyNewProject
MyNewProject
https://github.com/avadhvashisth/MyNewProject.git

Answer

Powershell can capture all the standard output to a string. Make sure you specify the path to your node.exe and include the file extension or Powershell will consider it a command:

$MyOutput = .node.exe index.js MyNewProject

$MyOutput should contain everything returned by node

We are here to answer your question about How to run node js script from powershell script and use the output of node js script in powershell script? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji