Guest User

Untitled

a guest
Oct 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. $pattern = "Get-SPSite"
  2. $path = "C:\_scripts\SharePoint\OnPrem"
  3.  
  4.  
  5. $files = Get-ChildItem -Path $path -Recurse -Include "*.ps1", "*.psm1"
  6.  
  7. $scanned = @()
  8.  
  9. foreach( $file in $files )
  10. {
  11. if( $scanned -notcontains $file.Directory.FullName -and $file.Directory.Parent.FullName -eq $path )
  12. {
  13. $scanned += $file.Directory.FullName
  14. Write-Host "Scanning: $($file.DirectoryName)" -ForegroundColor Cyan
  15. }
  16. else
  17. {
  18. Write-Verbose "Scanning: $($file.DirectoryName)"
  19. }
  20.  
  21. $patternMatches = Get-Content -Path $file.FullName | Select-String -Pattern $pattern
  22.  
  23. if( $patternMatches )
  24. {
  25. Write-Host "`t$($patternMatches.Matches.Count) match(es): $($file.FullName)" -ForegroundColor Green
  26. }
  27. else
  28. {
  29. Write-Verbose "No Match: $($file.FullName)"
  30. }
  31. }
Add Comment
Please, Sign In to add comment