I found a script that can delete files over X days old and changed it a bit so that i will scan different network folders to see if there are files that are older than X days. Now when i run the script with PowerShell ISE the script is working fine and doing what it should do. Taking about 1h
Now when i try to schedule the script with Windows Taskscheduler, the task starts and completes 10s later but the script didnt run. So no files were deleted?
Scheduled Task setting:
Run task with account that has logon as batch priviledges
Run wether user is logged on or not
Run with highest priviledges
Program/script: Run a program C:\windows\system32\windowspowershell\v1.0\powershell.exe
Arrgument: -File “C:\scripts\deletefiles.ps1"
Anybody has an idea what i'm doing wrong? Or why its not running the script?
The script can be found here