You can just spawn a child process "powershell.exe" and listen to stdout for command output and stderr for errors:
var spawn = require("child_process").spawn,child;
child = spawn("powershell.exe",["c:\temp\helloworld.ps1"]);
child.stdout.on("data",function(data){
console.log("Powershell Data: " + data);
});
child.stderr.on("data",function(data){
console.log("Powershell Errors: " + data);
});
child.on("exit",function(){
console.log("Powershell Script finished");
});
child.stdin.end(); //end input
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…