Skip to content

Instantly share code, notes, and snippets.

@acataluddi
Forked from vMarkusK/IIS-LogRotate.ps1
Created May 21, 2023 10:48
Show Gist options
  • Save acataluddi/3f40861e7c65ae3ad0cc4a0a0de1fb14 to your computer and use it in GitHub Desktop.
Save acataluddi/3f40861e7c65ae3ad0cc4a0a0de1fb14 to your computer and use it in GitHub Desktop.
$LogPath = "C:\inetpub\logs\LogFiles\W3SVC1\*"
$LogFiles = "*.log"
[int] $LogRetention = "-30" # in Days
Get-ChildItem $LogPath -Include $LogFiles -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays($LogRetention)} | Remove-Item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment