Skip to content

Instantly share code, notes, and snippets.

@ScriptingPro
Last active September 18, 2020 13:01
Show Gist options
  • Save ScriptingPro/9837d993ca095d003dbeafc636f1652a to your computer and use it in GitHub Desktop.
Save ScriptingPro/9837d993ca095d003dbeafc636f1652a to your computer and use it in GitHub Desktop.
Search your PS1 files and open in ISE
# 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