Some days ago I made a blog post about Select-String in Powershell. I created a “script” or a better a command to check logfiles for a specitifc text and copy the logfile to another place.
Get-ChildItem C:\temp -Filter *.log -Recurse | Select-String "Contoso" | Copy-Item -Destination C:\temp2
Now I added also a Startdate and a Enddate for the logfiles you wanna search in.
$Startdate = (get-date -year 2011 -month 3 -day 25) $Enddate = (get-date -year 2011 -month 3 -day 30) Get-ChildItem C:\temp -Filter *.log -Recurse | Where-Object {($_.LastWriteTime.Date -ge $Startdate.Date) -and ($_.LastWriteTime.Date -le $Enddate.Date)} | Select-String "Contoso" | Copy-Item -Destination C:\temp2