【发布时间】:2014-10-24 09:37:58
【问题描述】:
我们希望在 powershell 中为特定字符串“实时”跟踪几个日志文件。我们尝试使用“get-content”命令但没有运气,因为每次结果我们只收到一个文件的结果。我假设它是由“-wait”参数引起的。如果有任何其他方式来跟踪多个文件?我听说过运行空间,但我仍然不知道如何实现它。
我们的示例脚本如下
dir d:\test\*.txt -include *.txt | `
Get-Content -Wait | `
select-string "windows" | `
ForEach-Object {Write-EventLog -LogName Application -Source "Application error" -EntryType information -EventId 999 -Message $_}
任何帮助将不胜感激。
【问题讨论】:
-
使用
get-childitem代替 dir 并移除-wait开关,看看是否有效 -
感谢您的快速响应,但这不是我所需要的。我需要跟踪特定目录“live”中的几个 txt 文件,这就是我使用“-wait”选项的原因。
标签: powershell tail