I need to search for entry in logfiles between 3/8-2017 and 6/8-2017. So i make this powershell script to prevent search all IIS logfiles.
This script will copy all log files from the orginal IIS log path to a temp log directory, including the parent folder.
1 2 3 4 5 6 7 8 9 |
$destination = "c:\temp\log\" $files = get-childitem "C:\inetpub\logs\LogFiles\" -Recurse | ? {$_.LastWriteTime -ge "08/02/2017" -and $_.LastWriteTime -le "08/06/2017"} Foreach($file in $files) { #Test to see if the file already exists in the destination. If not => Move/Copy/Action you want :D $directory = Split-Path (Split-Path $file.fullname -Parent) -Leaf new-item $destination"\"$directory -type directory Copy-Item -Path $file.fullname -Destination $destination"\"$directory } |