1

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:\development\js-automation>node index.js MyNewProject
MyNewProject
https://github.com/avadhvashisth/MyNewProject.git
1
  • 1
    In your code, save the output as a variable and then call the function with the variable as an argument, then run your code in the terminal Commented Oct 6, 2020 at 18:28

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.