I want to browse through the folder3
and delete child files and folders, if their CreationTime
and LastWriteTime
are older than 1 month:
ls -r -force 'd:\folder1\folder2\folder3' |
where {($_.fullname -like 'd:\folder1\folder2\folder3\*') -and ($_.creationtime -le (get-date).addmonths(-1)) -and ($_.lastwritetime -le (get-date).addmonths(-1))} |
sort -desc fullname |
rm -force
How do I answer "No" to all the confirmations it asks when the folder is not empty? I only need folder deletion if it's empty.
-Confirm:$False
or -ErrorAction SilentlyContinue
statements do not help.