Skip to content

Instantly share code, notes, and snippets.

@rayterrill
Created July 9, 2017 22:57
Show Gist options
  • Select an option

  • Save rayterrill/1c35e9bf309e22854f8c902fe6dec4ba to your computer and use it in GitHub Desktop.

Select an option

Save rayterrill/1c35e9bf309e22854f8c902fe6dec4ba to your computer and use it in GitHub Desktop.
Use NodeJS to run some PowerShell code.
const shell = require('node-powershell');
let ps = new shell({
executionPolicy: 'Bypass',
noProfile: true,
debugMsg: false
});
ps.addCommand('./test.ps1')
ps.invoke()
.then(output => {
var outputParsed = JSON.parse(output)
console.log(outputParsed.value);
ps.dispose();
})
.catch(err => {
console.log(err);
ps.dispose();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment