Skip to content

Instantly share code, notes, and snippets.

@cryptrz
Created April 23, 2025 06:46
Show Gist options
  • Save cryptrz/a309d06be39ec0bac60c918e26a69dd0 to your computer and use it in GitHub Desktop.
Save cryptrz/a309d06be39ec0bac60c918e26a69dd0 to your computer and use it in GitHub Desktop.
Remove Sysmon logs older than 30 days
# Remove-SysmonOldLogs.ps1
$Folder = "C:\Sysmon"
$Days = 30
Get-ChildItem -Path $Folder -Recurse -File | Where-Object {
($_.LastWriteTime -lt (Get-Date).AddDays(-$Days))
} | Remove-Item -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment