D2GetSystemLog

Copy a log file. Works on Windows and Unix (differently - take a peek at the script itself to see how).

javascript · D2 (Deprecated)

Details

IDD2GetSystemLog
Languagejavascript
From Version5.0.0
Tagsagent endpoint

README

Copies a log file. This scripts works on Windows and Unix differently.

Script Data


Name Description
Script Type javascript
Tags agent, endpoint

Inputs


Argument Name Description
logName The name of the log to retrieve.

Outputs


There are no outputs for this script.

function copyLogUnix() {
  pack_file('/var/log/' + args.logName, args.logName);
}
function copyLogWindows() {
  var fileName = 'c:\\' + args.logName + '.log';
  var output = execute('wevtutil epl ' + args.logName + ' ' + fileName);
  if (!output.Success) {
    pack(output);
    throw output.Error + ': ';
  }
  pack_file(fileName, args.logName);
  del(fileName);
}
try {
  if (env.OS === 'windows') {
    copyLogWindows();
  } else  {
    copyLogUnix();
  }
} catch (ex) {
  pack('Error: ' + ex);
}