Skip to content

Instantly share code, notes, and snippets.

@jkantr
Forked from bobfrankly/myDerps.js
Last active November 30, 2017 20:05
Show Gist options
  • Save jkantr/9fedb6b3f47d9a79952bd040d8cc9706 to your computer and use it in GitHub Desktop.
Save jkantr/9fedb6b3f47d9a79952bd040d8cc9706 to your computer and use it in GitHub Desktop.
const shell = require('node-powershell');
let ps = new shell({
executionPolicy: 'Bypass',
noProfile: true
});
function psPing(thisIP) {
ps.addCommand('Test-Connection -quiet -count 1 ' + thisIP)
return ps.invoke()
.catch(err => {
console.warn(err);
ps.dispose();
});
}
psPing("192.168.0.1").then((result) => {
if (result === 'true') {
// do stuff
// return; <-- early return
}
// do stuff here, which is if it's not 'true'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment