Skip to content

Instantly share code, notes, and snippets.

@mwjcomputing
Created January 28, 2022 18:39
Show Gist options
  • Select an option

  • Save mwjcomputing/75a04758e39a20716eaa4362e3da50f0 to your computer and use it in GitHub Desktop.

Select an option

Save mwjcomputing/75a04758e39a20716eaa4362e3da50f0 to your computer and use it in GitHub Desktop.

Revisions

  1. mwjcomputing revised this gist Jan 28, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions New-MTail.ps1
    Original file line number Diff line number Diff line change
    @@ -25,5 +25,7 @@ function New-MTail {
    Written by Matthew Johnson (@mwjcomputing)
    .LINK
    https://mwjcomputing.com
    .LINK
    https://gist.github.com/mwjcomputing/75a04758e39a20716eaa4362e3da50f0
    #>
    }
  2. mwjcomputing created this gist Jan 28, 2022.
    29 changes: 29 additions & 0 deletions New-MTail.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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
    #>
    }