r/PowerShell • • 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

15 comments sorted by

View all comments

Show parent comment

3

u/Gormless_Shrimp_635 Aug 07 '26

If you create the task to run as a specific user and save it, I'm guessing it runs fine straight after creation.

If you then edit the task (schedule, script argument, etc.) and save it, sometimes it can strip the domain off the specified user without warning, and any subsequent runs fail with errors.

Edit the task and manually re-enter the specified user creds, save, and try run it.