Skip to content

Instantly share code, notes, and snippets.

@ChendrayanV
Last active February 5, 2018 14:42
Show Gist options
  • Save ChendrayanV/248f051af04030c53a466070a827a3ce to your computer and use it in GitHub Desktop.
Save ChendrayanV/248f051af04030c53a466070a827a3ce to your computer and use it in GitHub Desktop.
Call PowerShell in Node JS

Print Dingbat in Node JS using PowerShell

var shell = require('node-powershell');
let ps = new shell(
    {
        executionPolicy : 'bypass',
        noProfile : true
    }
);

ps.addCommand(`[string]::Concat("I " , 0x2764.ToChar($_)) , "node-PowerShell"`)
ps.invoke()
.then(output => {
  console.log(output);
})
.catch(err => {
  console.log(err);
  ps.dispose();
});

Output

Output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment