PS Scripts works only when 1 out of 2 is scheduled

Michal Rosiek 1 Reputation point
2022-12-06T12:29:14.933+00:00

Hi There,

I have created 2 scripts,
1 its Domain join uses MS Vault Secret Storage and is scheduled on system startup (that one works fine)

2 should need to be run on any user logon but fails with an error : Task Scheduler failed to start. Additional Data: Error Value: 2147943726.
Most of the responses to this error point to the incorrect password, but this is not the case as I can run the script manually. Also when I remove 1 task from the scheduler the second script works fine.
So far I have tried:

  • Changing the task settings - stop the existing instance/ run a new instance in parallel
  • Both tasks have been created with a local admin account
  • Both tasks Run whether user is logged on or not, with the Highest privileges, and win 10 configuration
  • I tried to run the 1 script via Local Group Policies but that comes with an access denied error while running the script on startup

I need 1 script (domain join) to run on startup so users can log in with the AD accounts after I create a new VM, the second script is variability client installation and synchronization, and it needs to be executed on any user logon.

Does anyone have any suggestions, please? what else I can try

Regards
Michal

Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 45,026 Reputation points
    2022-12-07T11:37:01.607+00:00

    Hi,

    Thank you for posting your query.

    Kindly follow the steps provided below to resolve your issue.

    Look in the History tab for errors.

    Change the task to run cmd.exe instead of powershell.exe. In the arguments field specify a bat file name, C:\PSScripts\DisableADUsers.bat

    Create the .bat file to call the PS script but also redirect stdout and stderr to a log file where you can check for error messages.

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\PSScripts\DisableADUsers.ps1" 1>C:\Windows\temp\DisableADUsers.log 2>&1

    Go to this link for your reference and other troubleshooting procedures https://learn.microsoft.com/answers/questions/357845/powershell-script-not-working-through-task-schedul.html

    https://learn.microsoft.com/answers/questions/977193/cant-get-powershell-script-to-run-if-scheduled-tas.html

    -------------------------------------------------------------------------------------------------------------------------------------

    If the answer is helpful kindly click "Accept as Answer" and up vote it.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.