Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

469
Views
¿Ejecutar el script powershell en el nodo js?

He visto preguntas similares aquí.

Una pregunta tuvo una respuesta aceptada de

 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

Estoy en Ubuntu, así que lo cambié a

 var spawn = require("child_process").spawn,child; child = spawn("/usr/bin/pwsh",["/srv/webroot/pauseRS.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

No obtengo ningún error cuando ejecuto el paquete del nodo, pero no parece estar ejecutando el script de PowerShell. No se registra nada en la consola.

El script de powershell solo ejecuta una solicitud web. Cuando ejecuto el script de powershell por sí mismo, funciona bien y funciona como se esperaba. Intentar llamar al script de powershell con el nodo no da ningún error y no produce ningún resultado.

Nodo 12.21.0

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¡Intenté generar un script de PowerShell que simplemente genera Hello World! usando node.js (12) en Ubuntu. A continuación se muestra el código. Parece funcionar bien. ¿Puedes compartir el contenido de tu archivo ps1?

 const { spawn } = require('child_process'); const ls = spawn('/usr/bin/pwsh', ['hello.ps1']); ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); }); ls.stderr.on('data', (data) => { console.error(`stderr: ${data}`); }); ls.on('close', (code) => { console.log(`child process exited with code ${code}`); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!