I am trying to create a script that zips files according to date(one day of Tomcat logs & one day of IIS Logs), then moves the appropriate zip file to a share.
I have tried to use several powershell scripts and batch files(.cmd) to get this done, all with no avail.
I have also tried to use http://exchangeserverpro.com/powershell-script-iis-logs-cleanup but cannot get it to work on a daily basis.
Can anyone help? I got the following to work but cant seem to figure out how to get the files to be exported before they are deleted
$purge = (Get-Date).AddDays(-1)
$path = "D:\Tomcat\apache-tomcat-7.0.39\logs"
# Delete files older than the $purge.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $purge } | Remove-Item -Force