-2

I have a Powershell-Script script.ps1 configured to be executed by a scheduled task on a Windows Server 2016 and it does its job but does not terminate. This causes problems when the Task Manager tries to start the task again for the next scheduled run.

The task is configured to start powershell.exe which then starts the script using -Command:

powershell -Command "& C:\Scripts\script.ps1"

The task is being executed by a domain user with admin privileges and configured to run regardless of whether the account is actually logged in or not.

Daniel
  • 578
  • 6
  • 18
  • Does this answer your question? [Powershell script does not run via Scheduled Tasks](https://stackoverflow.com/q/18259951/1701026) – iRon Mar 09 '20 at 12:28
  • no, this question is about scripts not running, mine did run just fine but did not terminate. Anyways, this related question's answer helped me out. https://stackoverflow.com/a/44416745/6703854 – Daniel Mar 09 '20 at 13:08

1 Answers1

0

had the same problem when I did not configure ExecutionPolicy you can read more about it here : https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy

alex
  • 916
  • 4
  • 12
  • 26