'Live tail of Windows log file
I have several Windows servers that I want to monitor a log file on them live and when a new line added with specific string to run a command on Linux server.
In order to tail the Windows log file I'm using the following command:
Get-Content <file name> -Wait | Select-String -Pattern <some string>
The command prints, all lines that having the string and new lines having the string.
How can I show just new lines from the moment I run the command and not all lines on the files ?
Solution 1:[1]
I solved the issue by running the following command:
get-content <file> -wait -tail 1 | select-string -pattern "<string>"
but need to make sure first that running it from PS V. 4
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Khalil Jomaa |
