Last active
September 18, 2020 13:01
-
-
Save ScriptingPro/9837d993ca095d003dbeafc636f1652a to your computer and use it in GitHub Desktop.
Search your PS1 files and open in ISE
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
# Find PowerShell Code Snippets Function | |
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 | %{psedit -filenames $_.name} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment