r/PowerShell • u/Swutter80 • Aug 07 '26
Question Scheduled task error 2147942401
From what I understand this error means its a bad command but I don't see what. It's a scheduled task with these commands:
Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add argument: -executionpolicy bypass -file "C:\Path_to_Script\Script.ps1"
Anyone see what I'm missing or do I have the code wrong?
9
Upvotes
View all comments
Show parent comment
1
u/Swutter80 Aug 07 '26
No I don't specify the start in path.
The account being used is service account with admin rights on the server and to the target it needs to access in the script.
Script runs when when I just run it normally. Ran it as myself and as the service account.
The script goes through a UNC path and targets files older then a certain date and deletes them.