利用powershell删除早于某个指定日期的文件
#delelte system update filesStop-Service wuauserv
Get-ChildItem -path C:\Windows\SoftwareDistribution | Remove-Item -Recurse -force
Start-Service wuauserv
#delete logs in specify website, just save logs in two days~
$TimeOutDays=1
$filePath="logspath"
$allFiles=get-childitem -path $filePath
foreach ($files in $allFiles)
{
$daypan=((get-date)-$files.lastwritetime).days
if ($daypan -gt $TimeOutDays)
{
remove-item $files.fullname -Recurse -force
}
}
页:
[1]