Created
July 9, 2017 22:57
-
-
Save rayterrill/1c35e9bf309e22854f8c902fe6dec4ba to your computer and use it in GitHub Desktop.
Use NodeJS to run some PowerShell code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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