Powershell–Delete files older than (xxx)
- Enis GOKTAY
- 28 Nis 2014
- 1 dakikada okunur
Merhaba,
Aşağıdaki scriptte, belirtilen bir günden sonra ilgili path’ten dosyaları silebiliriz
# Limit belirtilir.
$limit = (Get-Date).AddDays(-180)
#Path belirtilir. $path = “C:\inetpub\logs\LogFiles\W3SVC1\”
# Limit dahilinde ilgili path’teki dosyalar silinir.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
Comments