Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $pattern = "Get-SPSite"
- $path = "C:\_scripts\SharePoint\OnPrem"
- $files = Get-ChildItem -Path $path -Recurse -Include "*.ps1", "*.psm1"
- $scanned = @()
- foreach( $file in $files )
- {
- if( $scanned -notcontains $file.Directory.FullName -and $file.Directory.Parent.FullName -eq $path )
- {
- $scanned += $file.Directory.FullName
- Write-Host "Scanning: $($file.DirectoryName)" -ForegroundColor Cyan
- }
- else
- {
- Write-Verbose "Scanning: $($file.DirectoryName)"
- }
- $patternMatches = Get-Content -Path $file.FullName | Select-String -Pattern $pattern
- if( $patternMatches )
- {
- Write-Host "`t$($patternMatches.Matches.Count) match(es): $($file.FullName)" -ForegroundColor Green
- }
- else
- {
- Write-Verbose "No Match: $($file.FullName)"
- }
- }
Add Comment
Please, Sign In to add comment