Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function Find-Script
# Max results returned
$Maximum = 20
# Path to scripts directory
$StartPath = "E:\scripts"
Get-ChildItem -Path $StartPath -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue |
Select-String -SimpleMatch -Pattern $Keyword -List |
Select-Object -Property FileName, Path, Line -First $Maximum |
Out-GridView -Title 'Script Files Found'
$keyword = Read-Host "Enter keyword to search for"
Find-Script $keyword
# Prompt to exit script
Write-Host "`n`nPress any key to exit - also closes grid view window..." -fore "Yellow"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.