PowerShell: logifailide kustutaja

From ICO wiki
Revision as of 15:46, 22 May 2012 by Rtetsman (talk | contribs)
Jump to navigationJump to search

<#

   .SYNOPSIS
       	logifailide kustutamisskript

   .DESCRIPTION

kustutab kõik failide logid, mis on vanemad kui 30 päeva.

	.AUTHOR

Rasmus Tetsmann

  1. >

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 }