Skip to content

Instantly share code, notes, and snippets.

@mrbodean
Created January 3, 2020 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrbodean/2a407c2f23c7ba6304508feca158af03 to your computer and use it in GitHub Desktop.
Save mrbodean/2a407c2f23c7ba6304508feca158af03 to your computer and use it in GitHub Desktop.
$logs = Get-ChildItem -Path C:\inetpub\logs -Recurse -Filter *.log
$oldest = (get-date).AddDays(-30)
foreach($log in $logs){
if($log.LastWriteTime -lt $oldest){
$log.Delete()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment