diff --git a/lib/osinfo.js b/lib/osinfo.js index f2252ff..e73ece8 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -1122,15 +1122,13 @@ function shell(callback) { if (_windows) { try { const result = 'CMD'; - util.powerShell('$PSVersionTable').then(stdout => { + util.powerShell(`Get-CimInstance -className win32_process | where-object {$_.ProcessId -eq ${process.ppid} } | select Name`).then(stdout => { + let result = 'CMD'; if (stdout) { - const lines = stdout.toString().toLowerCase().split('\n').map(line => line.replace(/ +/g, ' ').replace(/ +/g, ':')); - const ps = getValue(lines, 'psversion'); - let result = 'CMD'; - if (ps) { - result = `PowerShell ${ps.split('.')[0] + (ps.split('.')[1] ? '.' + ps.split('.')[1] : '')}`; + if (stdout.toString().toLowerCase().indexOf('powershell') >= 0) { + result = 'PowerShell'; } - }; + } if (callback) { callback(result); }