Skip to content

Instantly share code, notes, and snippets.

@vMarkusK
Created March 14, 2016 09:54
Show Gist options
  • Save vMarkusK/2f1efeb28a96e3ca845f to your computer and use it in GitHub Desktop.
Save vMarkusK/2f1efeb28a96e3ca845f 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