我有一个配置为由 Windows Server 2016 上的计划任务执行的Powershell脚本script.ps1
,它可以执行工作,但不会终止。当任务管理器尝试再次启动任务以进行下一次预定运行时,这会导致问题。
该任务配置为启动powershell.exe
,然后使用-Command
启动脚本:
powershell -Command "& C:\Scripts\script.ps1"
该任务正在由具有管理员特权的域用户执行,并且配置为无论该帐户是否实际登录都可以运行。
答案 0 :(得分:0)
当我没有配置ExecutionPolicy时遇到了同样的问题 您可以在这里了解更多信息:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy