【问题标题】:Writing to the Windows Security Log写入 Windows 安全日志
【发布时间】:2014-12-24 00:44:19
【问题描述】:

我有一个脚本,当它完成显示运行它的用户时,我需要将审计事件写入 Windows 安全日志。

我可以写入安全日志以外的任何日志。

我该怎么做?

New-EventLog -LogName Security -Source "MyApp"
Write-EventLog -LogName Security -source "MyApp" -EntryType Information -EventId 1 -Message "Script run by X"

当名称从 Security 更改为 Application 或 System 时,它可以工作 - 但是,我在使用 Security 时不断收到以下信息:

Write-EventLog : 源日志“Security”的注册表项 无法打开“msevent”。在行:1 字符:1 + Write-EventLog -LogName Security -source "msevent" -EntryType Information -Event ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Write-EventLog],异常 + FullyQualifiedErrorId : AccessDenied,Microsoft.PowerShell.Commands.WriteEventLogCommand

我是管理员,不知道为什么会发生这种情况,即使在尝试修改注册表安全权限之后也是如此。

有人知道我该怎么做吗?

【问题讨论】:

    标签: windows security powershell logging


    【解决方案1】:

    MS 文档:

    只有本地安全机构 (Lsass.exe) 对 安全日志。没有其他帐户可以请求此权限。到 将事件写入安全日志,使用 AuthzReportSecurityEvent 功能。

    这里是文档的链接:Event Logging Security

    这里还有一个链接,涵盖了从 powershell 访问 Win API 的内容,如果您绝对必须使用安全日志,这应该有助于实施:Use PowerShell to Interact with the Windows API: Part 1

    很抱歉没有提供完整的示例,但由于时间限制,现在必须这样做。

    问候

    【讨论】:

    • 5 年过去了,但现在有 Vanara 项目可以帮助简化这一过程。
    【解决方案2】:

    提升的进程可以使用AuthzReportSecurityEvent function 写入安全事件日志。

    Vanara 项目为此 API 提供 .NET 互操作包装器,并以 Nuget package 的形式提供给 .NET 开发人员。它可能是创建可通过 PowerShell 使用的东西的良好起点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-01
      • 2010-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      相关资源
      最近更新 更多