Created
January 28, 2022 18:39
-
-
Save mwjcomputing/75a04758e39a20716eaa4362e3da50f0 to your computer and use it in GitHub Desktop.
New PowerShell Tail
This file contains hidden or 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 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