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.