PowerShell: logifailide kustutaja

From ICO wiki
Revision as of 15:49, 22 May 2012 by Rtetsman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
  1. Kustutab kõik failid mis on vanemad kui 30 päeva


param(

   [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Path,
   $DaysBack = 30)


$CurrentDate = Get-Date

$DatetoDelete = $CurrentDate.AddDays(-$Daysback)


if($Path -ne ""){

   Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item

}