Created
February 21, 2014 19:29
-
-
Save smasterson/9141598 to your computer and use it in GitHub Desktop.
This file contains 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 Find-Script | |
{ | |
param | |
( | |
[Parameter(Mandatory=$true)] | |
[string]$Keyword | |
) | |
# 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