Skip to content

Instantly share code, notes, and snippets.

@luthermonson
Created February 19, 2021 00:29
Show Gist options
  • Save luthermonson/b3ac6659dcef70fdb48b9423ba122944 to your computer and use it in GitHub Desktop.
Save luthermonson/b3ac6659dcef70fdb48b9423ba122944 to your computer and use it in GitHub Desktop.
powershell tail service logs
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