I am having an odd issue that I can't find or work out the answer to. I have a scheduled task that is running a Powershell script; I can run this fine both manually and on a schedule using my AD account, which is an admin on my machine and which I used to author the task; however, I would like to be able to use a different account to do this.
I have tried the local System account as well as a local admin I created, however with both all I get is the task hanging on Running status, result 0x41301
, until I end it.
The script is stored in a folder at the root of the C: drive, and the first line outputs a string confirming the script is running to a .txt
file in the same folder; when running the task as any account other than my AD user, this line is not output to the file.
Checking the history when running the task as System (for example) shows Powershell being run and the task starting successfully, but then no other events appear, and nothing happens.
I have the task set to run whether the user is logged in or not and with the highest privileges.
The action options are as follows:
Program/script: powershell.exe
Arguments: -NoProfile -ExecutionPolicy Bypass -File C:\ScriptFolder\Script.ps1
Start in: (blank)
Everything on the conditions tab is unticked.
I have also made sure every account that I have used to run the task (including System) has been manually added to be able to login as a batch job.
The script itself is creating a local admin account, or updating the password of that account if it already exists, and then inserting the password into a password vault.
I'm not sure what I am missing here. From what I can tell there should be no reason other admin accounts can't even start running the script.
Any help would be appreciated.