diff --git a/CHANGELOG.md b/CHANGELOG.md
index e56f1f7..7dae05f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -82,6 +82,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
+| 5.17.15 | 2023-05-29 | `powershell()` added NoProfile to speed up powershell (windows) |
| 5.17.14 | 2023-05-29 | `diskLayout()`, `osInfo()` fix parsing issues (mac OS) |
| 5.17.13 | 2023-05-24 | `typings` fix typings dynamicData, networkInterfaceDatass |
| 5.17.12 | 2023-02-28 | `uuid()` fix unique mac address issue (Android) |
diff --git a/docs/history.html b/docs/history.html
index 842938a..ab79b36 100644
--- a/docs/history.html
+++ b/docs/history.html
@@ -57,6 +57,11 @@
+
+ | 5.17.15 |
+ 2023-05-29 |
+ powerShell() added NoProfile attribute (windows) |
+
| 5.17.14 |
2023-05-29 |
diff --git a/lib/osinfo.js b/lib/osinfo.js
index 154ca38..3160084 100644
--- a/lib/osinfo.js
+++ b/lib/osinfo.js
@@ -1053,7 +1053,7 @@ function getUniqueMacAdresses() {
for (let dev in ifaces) {
if ({}.hasOwnProperty.call(ifaces, dev)) {
ifaces[dev].forEach(function (details) {
- if (details && details.mac && details.mac !== '00:00:00:00:00:00') {
+ if (details?.mac && details.mac !== '00:00:00:00:00:00') {
const mac = details.mac.toLowerCase();
if (macs.indexOf(mac) === -1) {
macs.push(mac);
diff --git a/lib/util.js b/lib/util.js
index d07d6c6..9aac93f 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -315,7 +315,7 @@ function getWmic() {
if (!fs.existsSync(wmicPath)) {
try {
const wmicPathArray = execSync('WHERE WMIC', execOptsWin).toString().split('\r\n');
- if (wmicPathArray && wmicPathArray.length) {
+ if (wmicPathArray?.length) {
wmicPath = wmicPathArray[0];
} else {
wmicPath = 'wmic';
@@ -378,14 +378,14 @@ function powerShellProceedResults(data) {
function powerShellStart() {
if (!_psChild) {
- _psChild = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
+ _psChild = spawn('powershell.exe', ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-Command', '-'], {
stdio: 'pipe',
windowsHide: true,
maxBuffer: 1024 * 20000,
encoding: 'UTF-8',
env: util._extend({}, process.env, { LANG: 'en_US.UTF-8' })
});
- if (_psChild && _psChild.pid) {
+ if (_psChild?.pid) {
_psPersistent = true;
_psChild.stdout.on('data', function (data) {
_psResult = _psResult + data.toString('utf8');
@@ -436,7 +436,7 @@ function powerShell(cmd) {
start: new Date()
});
try {
- if (_psChild && _psChild.pid) {
+ if (_psChild?.pid) {
_psChild.stdin.write(_psToUTF8 + 'echo ' + _psCmdStart + id + _psIdSeperator + '; ' + os.EOL + cmd + os.EOL + 'echo ' + _psCmdSeperator + os.EOL);
}
} catch (e) {
@@ -451,7 +451,7 @@ function powerShell(cmd) {
return new Promise((resolve) => {
process.nextTick(() => {
try {
- const child = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
+ const child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
stdio: 'pipe',
windowsHide: true,
maxBuffer: 1024 * 20000,
@@ -464,7 +464,7 @@ function powerShell(cmd) {
resolve(result);
});
}
- if (child && child.pid) {
+ if (child?.pid) {
child.stdout.on('data', function (data) {
result = result + data.toString('utf8');
});
@@ -514,7 +514,7 @@ function execSafe(cmd, args, options) {
resolve(result);
});
}
- if (child && child.pid) {
+ if (child?.pid) {
child.stdout.on('data', function (data) {
result += data.toString();
});
@@ -576,7 +576,7 @@ function smartMonToolsInstalled() {
if (_windows) {
try {
const pathArray = execSync('WHERE smartctl 2>nul', execOptsWin).toString().split('\r\n');
- if (pathArray && pathArray.length) {
+ if (pathArray?.length) {
_smartMonToolsInstalled = pathArray[0].indexOf(':\\') >= 0;
} else {
_smartMonToolsInstalled = false;