PowerTip: Create Function List and Find PowerShell Files

Doctor Scripto

SummaryUse Windows PowerShell to create a function list and find files.

Hey, Scripting Guy! Question How can I use Windows PowerShell to avoid repetitively typing “ls . –r *.ps1” to get a list of PowerShell files and then
           “ls . –r *.ps1 | sls function” to search the content of those files for a string?

Hey, Scripting Guy! Answer Add this function to your PowerShell profile:

function fps ($find) {    

    "Get-ChildItem . -Recurse *.ps1 $(if($find) { "| Select-String $find" })" |



Then, if you type `fps`, you’ll get a list of .ps1 files. To search for the string functions in each file, type `fps function`.


Discussion is closed.

Feedback usabilla icon