I am very new to PowerShell so please be nice and explain/comment if you answer with a bunch of code.
My goal : make big clean-up & free space on a server
My way to do that : identify folders than nobody accessed (even in read), after a specified date
currently I ran :
Get-ChildItem -Path $path -Recurse -Force -filter *.log | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
as a first step.
I also tried to make list of directories like :
Get-Children -Directory -recurse | where-object { $_.lastaccesstime -lt ((get-date).adddays( variablename )) } | select fullname, lastaccesstime, lastwritetime
want to do something like :
while find directory
read recurse sub-directories_properties_access_time
if last_access < specified_date then delete all recurse
next
done
0 Answers