Why does my scheduled task running a ps1-script not terminate?

302 Views Asked by At

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.

1

There are 1 best solutions below

0
alex On

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