我在脚本中有以下代码块,用于检查日志文件,如果找到特定行,则应继续。
$keywords=Get-Content "C:\Users\user\desktop\keywords.txt"
Get-Content "C:\Users\user\desktop\some.log" -tail 1 -wait |
ForEach-object {
foreach($word in $keywords) {
if($_ -match "$word") {
Write-EventLog -LogName Application -EventID 2001 -EntryType Information -Source serviceCheck -Message "[SUCCESS] The service has been initialized"
Write-Host "[SUCCESS] The service has been initialized"
}
}
} | Select -First 1
这记录了事件,但从不继续脚本的其余部分。如果我在if($_ -match "$word") {get-date}
中放了一些其他命令,例如或其他任何命令,它会工作并继续下一个命令。
如何在事件查看器中写入并继续?
1条答案
按热度按时间cgvd09ve1#
您需要输出 something,以便
Select -First 1
语句做出React: