$TargetFolder = "X:\30days"
$Childitems = Get-Childitem $TargetFolder -recurse |where {$_.attributes -ne "Directory"}
$mdate = Get-Date -format yyyyMMdd
foreach ($i in $Childitems)
{
if ($i.CreationTime -lt ($(Get-Date).AddDays(-30)))
{
Write-host $i.fullname -- $mdate
Remove-Item $i.FullName -force -recurse
}
}
No comments:
Post a Comment