-
-
Save jkantr/9fedb6b3f47d9a79952bd040d8cc9706 to your computer and use it in GitHub Desktop.
This file contains 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 | |
}); | |
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