【发布时间】:2014-05-22 23:06:40
【问题描述】:
我正在尝试使用 powershell 在 Windows 2k8 中跟踪日志文件,然后将其发送到 Windows 事件查看器。
我知道 powershell 可以通过运行“跟踪”日志:
Get-Content -Path C:\logs\events.log -Wait
这将实时跟踪日志(类似于 linux tail 中的 -f)。
Powershell 还可以写入 Windows 事件系统日志:
Write-EventLog System -source System -eventid 12345 -message "test"
我想知道如何(或是否)可以将尾日志结果作为 Write-EventLog 消息进行管道传输?
我在想,既然这是一个 Windows 环境,可能需要编写脚本来调用从 Get-Content 获取的消息变量?有谁知道怎么做,或者这是否可以做到?我的 google 搜索没有引导我进行实时 Windows 事件记录。
【问题讨论】:
标签: windows powershell