How can I troubleshoot Scheduled Task error 2147942401 when running PowerShell?

0
4
Asked By VelvetCedar47 On

I created a Windows Scheduled Task to run a PowerShell script, but it fails with error 2147942401 (0x80070001, ERROR_INCORRECT_FUNCTION). The task uses C:WindowsSystem32WindowsPowerShellv1.0powershell.exe with these arguments: -ExecutionPolicy Bypass -File "C:Path_to_ScriptScript.ps1". The script runs successfully when launched manually, both under my account and under the service account configured for the task. It accesses a UNC path and deletes files older than a specified date. I have not configured the task's "Start in" directory. What settings or permissions should I check?

3 Answers

Answered By OrbitMango8 On

Try setting the task's Start in directory to the folder containing the script, such as C:Path_to_Script, and simplify the command to powershell.exe with arguments -ExecutionPolicy Bypass -File "Script.ps1". Also verify that the service account can access the script folder and every directory above it. Adding Start-Transcript to the script can help capture what happens when it runs unattended.

Answered By NimbleQuartz53 On

Because the script accesses a UNC path, make sure the scheduled-task identity can authenticate to that remote resource. Running it manually as an administrator does not prove the service account has the same network access. If another server is involved, investigate delegated credentials or a possible double-hop issue. Also check whether the script was downloaded and needs to be unblocked before PowerShell will run it.

VelvetCedar47 -

The task uses a service account with administrative access on the server and the target, but I will verify its batch-logon right and access to the UNC path specifically.

Answered By QuietHarbor26 On

The hexadecimal form of 2147942401 is 0x80070001, which means ERROR_INCORRECT_FUNCTION. That does not necessarily identify the exact problem, so check the executable path, argument quoting, working directory, and the account selected in the task. Confirm that the account has the Log on as a batch job right and that the task is configured to run with the intended privileges.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.