Skip to content

Instantly share code, notes, and snippets.

@martin9700
Created October 18, 2015 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martin9700/bdaf7dcebffba49f5df8 to your computer and use it in GitHub Desktop.
Save martin9700/bdaf7dcebffba49f5df8 to your computer and use it in GitHub Desktop.
$KeepLogsFor = 15
$VerbosePreference = "Continue"
$LogPath = Split-Path $MyInvocation.MyCommand.Path
Get-ChildItem "$LogPath\*.log" | Where LastWriteTime -LT (Get-Date).AddDays(-$KeepLogsFor) | Remove-Item -Confirm:$false
$LogPathName = Join-Path -Path $LogPath -ChildPath "$($MyInvocation.MyCommand.Name)-$(Get-Date -Format 'MM-dd-yyyy').log"
Start-Transcript $LogPathName -Append
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment