Advertisement
Wasif_Hasan_

RecursiveStringSearch.ps1

Sep 18th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function RecursiveStringSearch($String,$Folder,$Regex){
  2. "Matches found in:`n"
  3. Get-ChildItem "$Folder" | Foreach {
  4.   If($Regex){
  5.     If((Get-Content "$_.Fullname" | Select-String -Pattern "$String")){
  6.       $_.Fullname
  7.     }
  8.   }Else{
  9.     If((Get-Content "$_.Fullname" | Select-String "$String")){
  10.       $_.Fullname
  11.     }
  12.   }
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement