尝试创建 ID 大于 1000 的简单事件,以使用 powershell 测试通知系统。
Write-EventLog –LogName System –Source FailoverClustering –EntryType Error –EventID 1793 –Message "This is a test message. Please Ignore."
返回的错误信息如下
Write-EventLog : The source name "FailoverClustering" does not exist on computer "localhost".
At line:1 char:1
+ Write-EventLog –LogName System –Source FailoverClustering –EntryType ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Write-EventLog], InvalidOperationException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteEventLogCommand
我读到一些关于某些来源需要注册的内容?如果没有,我不确定为什么当服务器事件日志中已经存在大量日志、事件、事件 ID 时它会抛出此错误。
该脚本正在同一服务器上执行,该服务器已经包含事件视图中的先前条目。
开关的顺序不正确。现在可以正常工作了。看例子
Write-EventLog -LogName "System" -Source "Service Control Manager" -EntryType "Information" -EventId 7036 -Message "This is a test. Please Ignore"