Skip to content

Instantly share code, notes, and snippets.

@willwm
Last active July 19, 2020 04:35
Show Gist options
  • Save willwm/4eee9f93e223229a60268808b4da4acc to your computer and use it in GitHub Desktop.
Save willwm/4eee9f93e223229a60268808b4da4acc to your computer and use it in GitHub Desktop.
# https://win32.io/posts/How-To-Find-Text-PowerShell
Get-ChildItem "C:\path\to\folder" -recurse | Where-Object { (Get-Content $_) -like '*TextToFind*' } | Select-Object { $_.FullName }
# ...as a function:
function Find-TextInFiles($searchPath, $text) {
Get-ChildItem $searchPath -recurse | Where-Object { (Get-Content $_) -like '*$text*' } | Select-Object { $_.FullName }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment