Created
February 19, 2021 00:29
-
-
Save luthermonson/b3ac6659dcef70fdb48b9423ba122944 to your computer and use it in GitHub Desktop.
powershell tail service logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function taill([string]$service) { | |
$idx = (Get-EventLog -LogName Application -Source $service -Newest 1).Index | |
while ($True) | |
{ | |
Start-Sleep -MilliSeconds 100 | |
$idx2 = (Get-EventLog -LogName Application -Source $service -Newest 1).index | |
if (-NOT($idx -eq $idx2)) { | |
Get-EventLog -logname Application -Source $service -Newest ($idx2 - $idx) | Sort index | Select-Object Message | |
} | |
$idx = $idx2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment