Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $searchpattern = "Error I want to search in log file"
- $Servers = @("MYWEBAPP42","MYWEBAPP43","MYWEBAPP60","MYWEBAPP61")
- foreach ($server in $servers)
- {
- $mypath = "\\" + $server + "\M$\SQLDBA\MyToolPath\LogFolder"
- $myfiles=Get-ChildItem $mypath | where {($_.CreationTime -ge $(Get-Date).AddHours(-120))}
- foreach ($file in $myfiles)
- {
- IF ( Get-Content $file.FullName | Select-String -Pattern $searchpattern )
- {
- Write-Host $file.FullName
- }
- }
- }
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement