PowerShell: logifailide kustutaja: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Rtetsman (talk | contribs)
No edit summary
Rtetsman (talk | contribs)
No edit summary
Line 4: Line 4:
   
   
     .DESCRIPTION
     .DESCRIPTION
kustutab kõik failide logid, mis on vanemad kui 30 päeva
     
                kustutab kõik failide logid, mis on vanemad kui 30 päeva
  .AUTHOR
  .AUTHOR
Rasmus Tetsmann
Rasmus Tetsmann

Revision as of 15:44, 22 May 2012

   .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 }