I've been looking around the web and on Stackoverflow but hadn't found an answer to this question. How would you execute a Powershell script from Node.js? The script is on the same server as the Node.js instance.
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- How to Debug/Register a Permanent WMI Event Which
- How can I do variable substitution in a here-strin
- google-drive can't get push notifications
- How to use a default value with parameter sets in
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- node连接远程oracle报错
- C#调用PowerShell的问题
- How can make folder with Firebase Cloud Functions
- EscapeDataString having differing behaviour betwee
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
You can just spawn a child process "powershell.exe" and listen to stdout for command output and stderr for errors:
In addition to the accepted answer, there is a Node.JS Library called Edge.js that allows various langugages to be executed from within Node. Including C#, J#, .Net, SQL, Python, PowerShell and other CLR languages.
Note that Edge.js requires PowerShell 3.0 & only works on Windows (many of the other features work on Mac and Linux too).
This option works for me, when the script is not already there, but you want to generate some commands dynamically, send them, and work with the results back on node.
Or you can just use Node-PowerShell.