IIS 7 and 7.5 rotate all logging

  • start powershell
  • set-executionpolicy remotesigned
  • Create a script with notepad
get-childitem -Path C:\inetpub\logs\LogFiles -recurse |
where-object {$_.lastwritetime -lt (get-date).addDays(-90)} |
Foreach-Object { del $_.FullName }
  • Save the script @ c:\scripts\del_old_logs.ps1
  • start cmd
  • run: powershell.exe c:\scripts\del_old_logs.ps1  -noprofile -Noninteractive
  • If you get a “child” question press A
  • Start task scheduler
  • Schedule the task
  • program powershell
  • c:\scripts\del_old_logs.ps1  -noprofile -Noninteractive

Sheduled Task

  • Run the task wheter user is logged on or not
  • Highest privileges not needed

Author: Thomas Faddegon

Bla bla bla