Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 日志分析器脚本问题_Windows_Vbscript_Logparser - Fatal编程技术网

Windows 日志分析器脚本问题

Windows 日志分析器脚本问题,windows,vbscript,logparser,Windows,Vbscript,Logparser,我一直在试图找出以下问题的解决方案: 我一直在构建一个VBScript,以使用 windows LogParser 2.2工具 该脚本的目标是解析已收集和保存的日志中的审核日志 evtx文件位于每周审核文件夹结构中。想象一下 您正在处理的是一个包含WMI服务的整个windows系统网络 已经运行,每周收集这些日志以供查看。因此,文件夹 结构每周保持一致,例如/../audits/date/windows/XXX.evt 这些每周审核文件的摘要文件是基于文本的,这不利于 每周审核数百台机器 我已经

我一直在试图找出以下问题的解决方案:

我一直在构建一个VBScript,以使用 windows LogParser 2.2工具

该脚本的目标是解析已收集和保存的日志中的审核日志 evtx文件位于每周审核文件夹结构中。想象一下 您正在处理的是一个包含WMI服务的整个windows系统网络 已经运行,每周收集这些日志以供查看。因此,文件夹 结构每周保持一致,例如/../audits/date/windows/XXX.evt

这些每周审核文件的摘要文件是基于文本的,这不利于 每周审核数百台机器

我已经计算了基本语法,这样我就可以使用 任何问题。我的奋斗伴随着我需要的附加功能

该脚本需要以下功能:

启动时,需要提示用户输入所需的文件路径 分析审计数据,例如…。/2013-07-03/windows/*

然后,用户的响应需要绑定到一个值,并用于替换 我在整个脚本中指定的变量。期望的结果是 脚本在用户标识的位置启动脚本中的查询事件

我尝试使用带有正则表达式对象的inputbox,但无法让脚本遍历并替换变量filePathReplace,以便脚本在指定的位置运行查询事件

我不在乎是否使用了输入框。最重要的是,我需要一种方法,为脚本提供一个文件路径,并在整个脚本中应用它,以便logparser在特定文件夹中启动我的指令

下面是我的一段摘录。非常感谢您的任何帮助。谢谢大家抽出时间

代码摘录这是脚本的核心组件和审核事件之一

Dim oLogQuery
Dim oEVTInputFormat
Dim oTPLOutputFormat 
Dim strQuery

Set oLogQuery = CreateObject("MSUtil.LogQuery")

' Create Input Format object
Set oEVTInputFormat = CreateObject("MSUtil.LogQuery.EventLogInputFormat")
oEVTInputFormat.direction = "BW"

' Create Output Format object
Set oTPLOutputFormat = CreateObject("MSUtil.LogQuery.TemplateOutputFormat")

' Create query text  (the variable substitution should occur where I state
' filePathReplace. To make the script run without this function, subsitiute
' that variable for 'Security'

' Audit log clearing - 517

oTPLOutputFormat.tpl = "C:\Program Files\Log Parser 2.2\EventFilters\EventLogs-TPL-517.tpl"

strQuery = "SELECT TimeGenerated, EventID, " & _
  "EXTRACT_TOKEN (Strings,3,'|') AS clientUserName, " & _
  "EXTRACT_TOKEN (Strings,4,'|') AS hostName, " & _
  "EXTRACT_TOKEN (Message,0,'Primary User Name') AS Message " & _ 
  "INTO 'C:\Program Files\Log Parser 2.2\EventFilters\AuditLogCleared-517.htm' " & _
  "FROM 'filePathReplace' " & _
  "WHERE EventID = 517"

oLogQuery.ExecuteBatch strQuery, oEVTInputFormat, oTPLOutputFormat
这种方法可以说是解决您问题的最佳方法。例如:

Set os = CreateObject("shell.application")
basedir = os.Namespace("C:\some\folder").Self.Path
Set fldr = os.BrowseForFolder(0, "Select Folder:", &h10&, basedir)
If Not fldr Is Nothing Then
  'do stuff
End If
像这样使用返回的对象:

strQuery = "SELECT ..." & _
  ...
  "FROM '" & fldr.Self.Path & "' " & _
  "WHERE EventID = 517"

非常感谢你的帮助!请避免发表感谢评论。对SO表示感谢的正确方式是投票和/或回答。