Function FindPattern { Clear-Host foreach ($server in $serverlist) { # change this two lines to affect the file location and type $Path = "\\$server\c$\Log Files\Calendar Repair Assistant" $Full = Get-ChildItem $Path -include *.log -recurse write-host searching host: $server ... foreach ($StringText in $StringTextList) { $List = select-string -pattern $StringText $Full foreach ($file in $List) {$file.Path; $i++} } } } $serverlist=('server1','server2',...) $StringTextList=('search string') # change this line to affect the searching pattern FindPatternNotes:
Swap the famous *.* for *.txt, thus: -include *.*
The -include switch only works when you also append the -recurse parameter.
The -include switch applies to the filename and extension and does NOT apply to the path.
No comments:
Post a Comment