Skip to content

Instantly share code, notes, and snippets.

@mwjcomputing
Created January 28, 2022 18:39
Show Gist options
  • Save mwjcomputing/75a04758e39a20716eaa4362e3da50f0 to your computer and use it in GitHub Desktop.
Save mwjcomputing/75a04758e39a20716eaa4362e3da50f0 to your computer and use it in GitHub Desktop.
New PowerShell Tail
function New-MTail {
param (
[Parameter(Mandatory = $true)]
[string]$File,
[Parameter(Mandatory = $true)]
[string]$SearchTerm
)
Get-Content -Path $File -tail 100 -wait | Select-String $SearchTerm
<#
.SYNOPSIS
Does a PowerShell tail
.DESCRIPTION
Does a PowerShell tail for the last 100 lines from file.
.EXAMPLE
PS C:\> New-MTail -File log.txt -SearchTerm error
Sets the Windows 11 Theme to light mode.
.INPUTS
System.String. The path to the file to tail.
System.String. The search term to trigger on.
.OUTPUTS
None
.NOTES
Written by Matthew Johnson (@mwjcomputing)
.LINK
https://mwjcomputing.com
.LINK
https://gist.github.com/mwjcomputing/75a04758e39a20716eaa4362e3da50f0
#>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment