1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
const shell = require('node-powershell'); const express = require('express') const app = express() let ps = new shell({ executionPolicy: 'Bypass', noProfile: true }); ps.addCommand('Get-Process | ConvertTo-Html -Property Name, Path, Company') ps.invoke() .then(output => { console.log(output); app.get('/procesos', function (req, res) { res.send(output); }) }) .catch(err => { console.log(err); ps.dispose(); }); let ps2 = new shell({ executionPolicy: 'Bypass', noProfile: true }); ps2.addCommand('Get-Service | ConvertTo-Html -Property Name, Path, Company') ps2.invoke() .then(output => { console.log(output); app.get('/servicios', function (req, res) { res.send(output); }) }) .catch(err => { console.log(err); ps2.dispose(); }); app.listen(3000, function () { console.log('Example app listening on port 3000!') }) |

