powershell - Tail a log file and if match trigger an actrion -
i using following line of code return recent line of log via powershell
get-content -path c:\folder\thisisalog.log -tail 1 -wait | {$_ -match "remote_http"} this works correctly , write console each time log matches "remote_http" logged.
however run script when returned. far have tried add variable , check if null no luck , have tried using if statements no success. trying both of these script runs indefinitely no output console or triigers.
i think may -wait causing issue.
just it
get-content -path c:\folder\thisisalog.log -tail 1 -wait | % {if ($_ -match "remote_http") {write-host "run code here"}} or directly where
get-content -path c:\folder\thisisalog.log -tail 1 -wait | {if ($_ -match "remote_http") {write-host "run code here"}}
Comments
Post a Comment