windows porwerShell improvements
This commit is contained in:
parent
909f4e227f
commit
022c2fb9b4
@ -194,7 +194,7 @@ function audio(callback) {
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
util.powerShell('Get-WmiObject Win32_SoundDevice | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_SoundDevice | select DeviceID,StatusInfo,Name,Manufacturer | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
|
||||
@ -225,7 +225,7 @@ module.exports = function (callback) {
|
||||
if (_windows) {
|
||||
try {
|
||||
const workload = [];
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_Battery | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_Battery | select BatteryStatus, DesignCapacity, DesignVoltage, EstimatedChargeRemaining, DeviceID | fl'));
|
||||
workload.push(util.powerShell('(Get-WmiObject -Class BatteryStaticData -Namespace ROOT/WMI).DesignedCapacity'));
|
||||
workload.push(util.powerShell('(Get-WmiObject -Class BatteryFullChargedCapacity -Namespace ROOT/WMI).FullChargedCapacity'));
|
||||
util.promiseAll(
|
||||
|
||||
@ -158,7 +158,7 @@ function bluetoothDevices(callback) {
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
util.powerShell('Get-WmiObject Win32_PNPEntity | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_PNPEntity | select PNPClass, Name, Manufacturer | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
|
||||
@ -797,8 +797,8 @@ function getCpu() {
|
||||
if (_windows) {
|
||||
try {
|
||||
const workload = [];
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_processor | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_processor | select Name, Revision, L2CacheSize, L3CacheSize, Manufacturer, MaxClockSpeed, Description, UpgradeMethod, Caption, NumberOfLogicalProcessors, NumberOfCores | fl'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl'));
|
||||
// workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
|
||||
workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent'));
|
||||
|
||||
@ -1425,7 +1425,7 @@ function cpuCache(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
util.powerShell('Get-WmiObject Win32_processor | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_processor | select L2CacheSize, L3CacheSize | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let lines = stdout.split('\r\n');
|
||||
result.l1d = 0;
|
||||
@ -1435,7 +1435,7 @@ function cpuCache(callback) {
|
||||
if (result.l2) { result.l2 = parseInt(result.l2, 10) * 1024; }
|
||||
if (result.l3) { result.l3 = parseInt(result.l3, 10) * 1024; }
|
||||
}
|
||||
util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl ').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const parts = stdout.split(/\n\s*\n/);
|
||||
parts.forEach(function (part) {
|
||||
|
||||
@ -127,7 +127,7 @@ function fsSize(callback) {
|
||||
if (_windows) {
|
||||
try {
|
||||
// util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
|
||||
util.powerShell('Get-WmiObject Win32_logicaldisk | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_logicaldisk | select Caption,FileSystem,FreeSpace,Size | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let devices = stdout.toString().split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
@ -400,7 +400,8 @@ function blockDevices(callback) {
|
||||
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'Local', 'Network', 'CD/DVD', 'RAM'];
|
||||
try {
|
||||
// util.wmic('logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value').then((stdout, error) => {
|
||||
util.powerShell('Get-CimInstance -ClassName Win32_LogicalDisk | Format-List *').then((stdout, error) => {
|
||||
// util.powerShell('Get-WmiObject Win32_logicaldisk | select Caption,DriveType,Name,FileSystem,Size,VolumeSerialNumber,VolumeName | fl').then((stdout, error) => {
|
||||
util.powerShell('Get-CimInstance -ClassName Win32_LogicalDisk | select Caption,DriveType,Name,FileSystem,Size,VolumeSerialNumber,VolumeName | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let devices = stdout.toString().split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
@ -1167,8 +1168,8 @@ function diskLayout(callback) {
|
||||
if (_windows) {
|
||||
try {
|
||||
const workload = [];
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_DiskDrive | fl *'));
|
||||
workload.push(util.powerShell('Get-PhysicalDisk | Format-List'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_DiskDrive | select Caption,Size,Status,PNPDeviceId,BytesPerSector,TotalCylinder,TotalHeads,TotalSectors,TotalTracks,TracksPerCylinder,SectorsPerTrack,FirmwareRevision,SerialNumber,InterfaceType | fl'));
|
||||
workload.push(util.powerShell('Get-PhysicalDisk | select BusType,MediaType,FriendlyName,Model,SerialNumber,Size | fl'));
|
||||
if (util.smartMonToolsInstalled()) {
|
||||
try {
|
||||
const smartDev = JSON.parse(execSync('smartctl --scan -j'));
|
||||
|
||||
@ -504,7 +504,7 @@ function memLayout(callback) {
|
||||
const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|');
|
||||
|
||||
try {
|
||||
util.powerShell('Get-WmiObject Win32_PhysicalMemory | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_PhysicalMemory | select DataWidth,TotalWidth,Capacity,BankLabel,MemoryType,SMBIOSMemoryType,ConfiguredClockSpeed,FormFactor,Manufacturer,PartNumber,SerialNumber,ConfiguredVoltage,MinVoltage,MaxVoltage | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let devices = stdout.toString().split(/\n\s*\n/);
|
||||
devices.shift();
|
||||
|
||||
@ -1306,7 +1306,7 @@ function networkStatsSingle(iface) {
|
||||
let ifaceName = ifaceSanitized;
|
||||
|
||||
// Performance Data
|
||||
util.powerShell('Get-WmiObject Win32_PerfRawData_Tcpip_NetworkInterface | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_PerfRawData_Tcpip_NetworkInterface | select Name,BytesReceivedPersec,PacketsReceivedErrors,PacketsReceivedDiscarded,BytesSentPersec,PacketsOutboundErrors,PacketsOutboundDiscarded | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const psections = stdout.toString().split(/\n\s*\n/);
|
||||
perfData = parseLinesWindowsPerfData(psections);
|
||||
|
||||
@ -330,7 +330,7 @@ function osInfo(callback) {
|
||||
result.release = result.kernel;
|
||||
try {
|
||||
const workload = [];
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_OperatingSystem | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_OperatingSystem | select Caption,SerialNumber,BuildNumber,ServicePackMajorVersion,ServicePackMinorVersion | fl'));
|
||||
// workload.push(execPromise('systeminfo', util.execOptsWin));
|
||||
// workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
|
||||
workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent'));
|
||||
|
||||
@ -186,7 +186,7 @@ function printer(callback) {
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
util.powerShell('Get-WmiObject Win32_Printer | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_Printer | select PrinterStatus,Name,DriverName,Local,Default,Shared | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
|
||||
@ -343,7 +343,7 @@ function system(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
util.powerShell('Get-WmiObject Win32_ComputerSystemProduct | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_ComputerSystemProduct | select Name,Vendor,Version,IdentifyingNumber,UUID | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
// let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
|
||||
let lines = stdout.split('\r\n');
|
||||
@ -369,7 +369,7 @@ function system(callback) {
|
||||
if (manufacturer.startsWith('xen')) { result.virtualHost = 'Xen'; }
|
||||
if (manufacturer.startsWith('qemu')) { result.virtualHost = 'KVM'; }
|
||||
}
|
||||
util.powerShell('Get-WmiObject MS_Systeminformation -Namespace "root/wmi" | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject MS_Systeminformation -Namespace "root/wmi" | select systemsku | fl ').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let lines = stdout.split('\r\n');
|
||||
result.sku = util.getValue(lines, 'systemsku', ':');
|
||||
@ -506,7 +506,7 @@ function bios(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
util.powerShell('Get-WmiObject Win32_bios | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_bios | select Description,Version,Manufacturer,ReleaseDate,BuildNumber,SerialNumber | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\r\n');
|
||||
const description = util.getValue(lines, 'description', ':');
|
||||
@ -662,7 +662,7 @@ function baseboard(callback) {
|
||||
if (_windows) {
|
||||
try {
|
||||
const workload = [];
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_baseboard | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_baseboard | select Model,Manufacturer,Product,Version,SerialNumber,PartNumber,SKU | fl'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_physicalmemoryarray | select MaxCapacity, MemoryDevices | fl'));
|
||||
util.promiseAll(
|
||||
workload
|
||||
@ -795,7 +795,7 @@ function chassis(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
util.powerShell('Get-WmiObject Win32_SystemEnclosure | fl *').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_SystemEnclosure | select Model,Manufacturer,ChassisTypes,Version,SerialNumber,PartNumber,SKU | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\r\n');
|
||||
|
||||
|
||||
@ -263,7 +263,7 @@ function usb(callback) {
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
util.powerShell('Get-WmiObject CIM_LogicalDevice | where { $_.Description -match "USB"}').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject CIM_LogicalDevice | where { $_.Description -match "USB"} | select Name,CreationClassName,DeviceId,Manufacturer | fl').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
|
||||
@ -253,8 +253,8 @@ function users(callback) {
|
||||
// Promise.all(
|
||||
// workload
|
||||
// ).then(data => {
|
||||
let cmd = 'Get-WmiObject Win32_LogonSession | fl *' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_LoggedOnUser | fl *' + '; echo \'#-#-#-#\';';
|
||||
let cmd = 'Get-WmiObject Win32_LogonSession | select LogonId,StartTime | fl' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_LoggedOnUser | select antecedent,dependent | fl ' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="sessionid";Expression={$_.SessionId}}, @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'query user';
|
||||
util.powerShell(cmd).then(data => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user