gpt4 book ai didi

windows - 写入 Windows 安全日志

转载 作者:可可西里 更新时间:2023-11-01 10:05:47 27 4
gpt4 key购买 nike

我有一个脚本,当它完成显示运行它的用户时,我需要将审计事件写入 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 : The registry key for the log "Security" for source "msevent" could not be opened. At line:1 char:1 + Write-EventLog -LogName Security -source "msevent" -EntryType Information -Event ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Write-EventLog], Exception + FullyQualifiedErrorId : AccessDenied,Microsoft.PowerShell.Commands.WriteEventLogCommand

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

有人知道我该怎么做吗?

最佳答案

MS 文档:

Only the Local Security Authority (Lsass.exe) has write permission for the Security log. No other account can request this privilege. To write an event to the Security log, use the AuthzReportSecurityEvent function.

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

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

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

问候

关于windows - 写入 Windows 安全日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26611265/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com