PowerShell: logifailide kustutaja

From ICO wiki
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

}