I am trying to delete files from a 2008 Windows Server that are older than 180 days based on the last modified date. I am using ForFiles in order to attempt to do this. When I run the command interactively as domain admin on the server, the command executes. When I setup a task within Windows task scheduler, the task fails to run with a return code of 1.
The below command is the command I am running.
forfiles /p "E:" /s /m *.* /D -180 /c "cmd /c del @path && echo"
I have also tried the below: