├── README.md └── file_search.ps1 /README.md: -------------------------------------------------------------------------------- 1 | # PowerShell-File-Search 2 | Searches for .txt files containing specified string in all drives. 3 | -------------------------------------------------------------------------------- /file_search.ps1: -------------------------------------------------------------------------------- 1 | function search { 2 | param($search) 3 | $drives = $drives = (get-volume | where-Object {$_.DriveLetter -like "?"}).DriveLetter 4 | foreach ($drive in $drives) { 5 | Write-Host "[*]Searching in $drive`:\" 6 | $files += Get-ChildItem -Recurse -Path "$drive`:\" -Filter "*.txt" -ErrorAction SilentlyContinue | Select-String "$search" -List -ErrorAction SilentlyContinue | Select Path 7 | } 8 | 9 | foreach ($file in $files.Path) { 10 | if ("$file" -like "*txt*") { 11 | Write-Host "[+] $file" 12 | } 13 | } 14 | } 15 | --------------------------------------------------------------------------------