写入Windows安全日志
我有一个脚本,我需要向Windows安全日志写入一个审计事件,当它完成时显示用户运行它。写入Windows安全日志
我可以写入除安全日志之外的任何日志。
我该怎么做?
New-EventLog -LogName Security -Source "MyApp"
Write-EventLog -LogName Security -source "MyApp" -EntryType Information -EventId 1 -Message "Script run by X"
当名字是从安全更改为应用程序或系统,它的作品 - 但,我不断收到以下使用安全性时:
写事件日志:注册表项日志“安全“源 ”msevent“无法打开。在行:1 char:1 + Write-EventLog -LogName Security -source“msevent”-EntryType Information -Event ... + ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ + CategoryInfo:PermissionDenied:(:) [写入事件日志],异常 + FullyQualifiedErrorId:存取遭拒,Microsoft.PowerShell.Commands.WriteEventLogCommand
我是管理员和不知道为什么会发生这种情况,即使在尝试修改注册表安全权限后。
有谁知道我该怎么做?
MS文档:
只有本地安全机构(Lsass.exe中)具有写权限 安全日志。没有其他帐户可以请求此特权。要将 事件写入安全日志,请使用AuthzReportSecurityEvent 函数。
这里是对文档的链接:Event Logging Security
而且,这里是覆盖访问来自PowerShell中的赢API,它应该在的情况下实现帮你绝对要使用安全日志的链接:Use PowerShell to Interact with the Windows API: Part 1
我很抱歉没有提供一个完整的例子,但由于时间的限制,现在不得不这样做。
Regards