Created
July 11, 2019 15:53
-
-
Save crshnbrn66/a0349e1a7f79c1aa4d01ca50ae259d36 to your computer and use it in GitHub Desktop.
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 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