I have a powershell script that runs on 1 machines but remotes out to other machines to collect system information. The script works fine when I run it manually, but it will not run as a scheduled task. I have it setup with the action "start a program" with the program/script set to run powershell.exe and the argument set to
-NoProfile -NoLogo -NoExit -NonInteractive -ExecutionPolicy Bypass -File filepath
I have tried the task with my admin credentials and by running as SYSTEM, same results with both sets of permissions. Any suggestions?
Asked
Active
Viewed 2,208 times
1

Aztec22
- 31
- 7
-
With system or a serviceuser, it should be sufficient to start a program with C:\Windows\system32\windowspowershell\v1.0\powershell.exe -executionpolicy remotesigned C:\scriptpath\script.ps1 - shouldnt need to be bypassed. – Bowshock Feb 09 '22 at 14:21
-
@Bowshock Thank you for the suggestion! I tried the change and still nothing. Task scheduler says that its running, but nothing is happening (the beginning of the script creates a folder with text files in C:\temp. nothing is being created). The task times out and gives a completed message; both with the same time stamp – Aztec22 Feb 09 '22 at 15:05
-
If you literally have double-quotes around the options, try it without them. I would try monitoring it with sysinteranals free process monitor. – js2010 Feb 09 '22 at 16:19
-
@js2010 no quotes around the argument. Sorry, that was my way of separating the text, I didn't format the post correctly. I've fixed it now. – Aztec22 Feb 09 '22 at 16:44
-
Note that -noexit means it never finishes. – js2010 Feb 09 '22 at 18:10
-
@js2010 With the -noexit, the task runs for 9 hours and then quits, despite the timeout being set to 12 hours. Without the -noexit, the task is triggered and immediately marked as complete; nothing running in the background and no results from the powershell script. – Aztec22 Feb 09 '22 at 19:29