Skip to content

Instantly share code, notes, and snippets.

@RhysC
Last active August 29, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RhysC/74196ba89016f858447b to your computer and use it in GitHub Desktop.
Save RhysC/74196ba89016f858447b to your computer and use it in GitHub Desktop.
Recursive file search
function search-files {
param ( [string]$fileFilter,
[string]$text)
$PathArray = @()
Get-ChildItem -Filter $fileFilter -Recurse |
Where-Object { $_.Attributes -ne "Directory"} |
ForEach-Object {
If (Get-Content $_.FullName | Select-String -Pattern $text) {
$PathArray += $_.FullName
# $PathArray += $_.FullName
}
}
Write-Host "Contents of ArrayPath:"
$PathArray | ForEach-Object {$_}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment