Skip to content

Instantly share code, notes, and snippets.

@jfrantz1-r7
Created October 10, 2018 15:33
Show Gist options
  • Save jfrantz1-r7/e86a8f71a84df61960fb4bfa422803e8 to your computer and use it in GitHub Desktop.
Save jfrantz1-r7/e86a8f71a84df61960fb4bfa422803e8 to your computer and use it in GitHub Desktop.
$limit = (Get-Date).AddDays(-7)
$path = "C:\inetpub\Logs\w3svc"
# Delete files older than the $limit.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment