shell() added pawershell detection

This commit is contained in:
Sebastian Hildebrandt 2025-01-07 16:52:52 +01:00
parent c7d4751518
commit f3c402248e

View File

@ -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);
}