定期删除日志powershell脚本

例: 定期删除3天前的日志

$FilePath = "C:\Windows\System32\LogFiles"
$DaysAgo=3
$Today=Get-Date  

Get-ChildItem -Path  $FilePath "*.log" | Where-Object {$_.LastWriteTime -lt $Today.AddDays(-$DaysAgo)} |Remove-Item

猜你喜欢

转载自blog.51cto.com/magic3/2444165