PowerShell: logifailide kustutaja: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
1 | |||
# Kustutab kõik failid mis on vanemad kui 30 päeva | |||
02 | 02 | ||
param( | param( |
Revision as of 15:47, 22 May 2012
1
- Kustutab kõik failid mis on vanemad kui 30 päeva
02 param( 03
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Path,
04
$DaysBack = 30)
05
06 $CurrentDate = Get-Date 07 $DatetoDelete = $CurrentDate.AddDays(-$Daysback) 08
09 if($Path -ne ""){ 10
Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item
11 }