1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 16:23:25 +00:00

Updated sysinfo/volumes

This commit is contained in:
Bryan Roe
2021-02-04 23:24:31 -08:00
parent 19e7d9e876
commit ae33e264c5
2 changed files with 58 additions and 33 deletions

File diff suppressed because one or more lines are too long

View File

@@ -101,45 +101,70 @@ function windows_wmic_results(str)
function windows_volumes() function windows_volumes()
{ {
var a, i, tokens, key; var promise = require('promise');
var ret = {}; var p1 = new promise(function (res, rej) { this._res = res; this._rej = rej; });
var p2 = new promise(function (res, rej) { this._res = res; this._rej = rej; });
p1._p2 = p2;
p2._p1 = p1;
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-']); var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-']);
p1.child = child;
child.promise = p1;
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('Get-Volume | Select-Object -Property DriveLetter,FileSystemLabel,FileSystemType,Size,DriveType | ConvertTo-Csv -NoTypeInformation\nexit\n'); child.stdin.write('Get-Volume | Select-Object -Property DriveLetter,FileSystemLabel,FileSystemType,Size,DriveType | ConvertTo-Csv -NoTypeInformation\nexit\n');
child.waitExit(); child.on('exit', function (c)
a = child.stdout.str.trim().split('\r\n');
for (i = 1; i < a.length; ++i)
{ {
tokens = a[i].split(','); var a, i, tokens, key;
if (tokens[0] != '') var ret = {};
{
ret[tokens[0].split('"')[1]] =
{
name: tokens[1].split('"')[1],
type: tokens[2].split('"')[1],
size: tokens[3].split('"')[1],
removable: tokens[4].split('"')[1] == 'Removable'
};
}
}
child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-']); a = this.stdout.str.trim().split('\r\n');
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); for (i = 1; i < a.length; ++i)
child.stdin.write('Get-BitLockerVolume | Select-Object -Property MountPoint,VolumeStatus,ProtectionStatus | ConvertTo-Csv -NoTypeInformation\nexit\n');
child.waitExit();
a = child.stdout.str.trim().split('\r\n');
for (i = 1; i < a.length; ++i)
{
tokens = a[i].split(',');
key = tokens[0].split(':').shift().split('"').pop();
if (ret[key] != null)
{ {
ret[key].volumeStatus = tokens[1].split('"')[1]; tokens = a[i].split(',');
ret[key].protectionStatus = tokens[2].split('"')[1]; if (tokens[0] != '')
{
ret[tokens[0].split('"')[1]] =
{
name: tokens[1].split('"')[1],
type: tokens[2].split('"')[1],
size: tokens[3].split('"')[1],
removable: tokens[4].split('"')[1] == 'Removable'
};
}
} }
} this.promise._res({ r: ret, t: tokens });
return (ret); });
p1.then(function (j)
{
var ret = j.r;
var tokens = j.t;
var child = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-']);
p2.child = child;
child.promise = p2;
child.tokens = tokens;
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('Get-BitLockerVolume | Select-Object -Property MountPoint,VolumeStatus,ProtectionStatus | ConvertTo-Csv -NoTypeInformation\nexit\n');
child.on('exit', function ()
{
var i;
var a = this.stdout.str.trim().split('\r\n');
for (i = 1; i < a.length; ++i)
{
tokens = a[i].split(',');
key = tokens[0].split(':').shift().split('"').pop();
if (ret[key] != null)
{
ret[key].volumeStatus = tokens[1].split('"')[1];
ret[key].protectionStatus = tokens[2].split('"')[1];
}
}
this.promise._res(ret);
});
});
return (p2);
} }
function windows_identifiers() function windows_identifiers()
@@ -474,7 +499,7 @@ module.exports.isVM = function isVM()
if (process.platform == 'win32') if (process.platform == 'win32')
{ {
module.exports.volumes = windows_volumes; module.exports.volumes_promise = windows_volumes;
} }
// bios_date = BIOS->ReleaseDate // bios_date = BIOS->ReleaseDate