Skip to content

Instantly share code, notes, and snippets.

@crshnbrn66
Created July 11, 2019 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crshnbrn66/a0349e1a7f79c1aa4d01ca50ae259d36 to your computer and use it in GitHub Desktop.
Save crshnbrn66/a0349e1a7f79c1aa4d01ca50ae259d36 to your computer and use it in GitHub Desktop.
function findit
{
param
(
[Parameter(Mandatory=$True,Position=0)][string]$SearchString,
[Parameter(Mandatory=$False)]$Path = "$env:USERPROFILE\Documents",
[Parameter(Mandatory=$False)]$Filter = "*.ps1"
)
Get-ChildItem -Path $Path -Filter $Filter -Recurse | Select-String $SearchString | select path, @{n="MatchingLines";e={"$($_.LineNumber.tostring("000")): $($_.Line -replace "^[ \t]*",'')"}} | group path | select name, @{n="Matches";e={$_.Group.MatchingLines | Out-String}} | Out-GridView -PassThru | %{notepad -filenames $_.name}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment