I am trying to get the below PowerShell script to work using Task Scheduler. The problem is that it wont delete any files.
When I run it manually it needs a confirma
This worked for me:
Get-ChildItem -Path "FolderToDelete" -Directory -recurse | where {$_.LastWriteTime -le $(get-date).Affffdays(-7)} | Remove-Item -recurse -force