Last active
August 29, 2015 14:28
-
-
Save RhysC/74196ba89016f858447b to your computer and use it in GitHub Desktop.
Recursive file search
This file contains hidden or 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 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