PowerShell: logifailide kustutaja: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
# | |||
. | .SYNOPSIS | ||
logifailide kustutamisskript | |||
.DESCRIPTION | |||
Kustutab kõik failide logid, mis on vanemad kui 30 päeva | |||
.AUTHOR | |||
Rasmus Tetsmann | |||
#> | |||
02 | 02 | ||
param( | param( |
Revision as of 15:42, 22 May 2012
.SYNOPSIS logifailide kustutamisskript .DESCRIPTION
Kustutab kõik failide logid, mis on vanemad kui 30 päeva
.AUTHOR
Rasmus Tetsmann
- >
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 }