简体   繁体   English

Powershell 脚本未在任务计划程序上运行

[英]Powershell script not running on Task Scheduler

I have a PS script that opens Excel (Com Object), processes a bunch of information, re-saves, and then sends some critical information via e-mail.我有一个 PS 脚本,可以打开 Excel(Com Object),处理一堆信息,重新保存,然后通过电子邮件发送一些关键信息。 The script runs great, and when I run it from the Run Console, it works great as well.该脚本运行良好,当我从运行控制台运行它时,它也运行良好。 However, when I schedule it as a task in the Task Scheduler it is not working properly.但是,当我在 Task Scheduler 中将其安排为任务时,它无法正常工作。 The task seems to "successfully run" every single time, but I do not get the output e-mail that I am supposed to get.该任务似乎每次都“成功运行”,但我没有收到我应该收到的输出电子邮件。 I have run many other PS Scripts without a problem using the same configuration in the task scheduler.我在任务调度程序中使用相同的配置运行了许多其他 PS 脚本,没有问题。 Could this have something to do with opening Excel as part of a script scheduled?这可能与将 Excel 作为预定脚本的一部分打开有关吗? Any thoughts are welcome.欢迎任何想法。

I solved this issue using the answer from @briantist in PowerShell script won't execute as a Windows scheduled task , but I wanted to isolate exactly which switch was solving the problem.我在PowerShell 脚本中使用@briantist 的答案解决了这个问题, 不会作为 Windows 计划任务执行,但我想确切地隔离哪个开关正在解决问题。

It had nothing to do with -ExecutionPolicy , -Noninteractive , -NoLogo , -NoProfile or any other system privilege, user account running the script, etc.它与-ExecutionPolicy-Noninteractive-NoLogo-NoProfile或任何其他系统权限、运行脚本的用户帐户等-NoProfile

Just needed to add -File in front of the script path in the Task Scheduler > Actions > Arguments field.只需要在Task Scheduler > Actions > Arguments字段中的脚本路径前面添加-File Without this switch PowerShell was launching and the task history was showing Action Completed , but the script was not executing.没有这个开关,PowerShell 正在启动,任务历史记录显示Action Completed ,但脚本没有执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Powershell 脚本适用于 ISE/控制台,但不适用于任务计划程序 - Powershell script works in ISE / Console but not Task Scheduler 如何在任务调度程序中使用 VBA 正确运行 powershell 脚本? - How to properly run a powershell script using VBA in a task scheduler? 通过任务计划程序运行时,Powershell脚本停止工作 - Powershell script stops working when ran through task scheduler 我无法让 powershell 在任务计划程序中运行 - I cant get powershell to run in task scheduler 任务计划程序正在运行,但未完成或无法正常工作VBscript - Task Scheduler running but not finishing or working properly VBscript Excel 宏通过 powershell 运行,但在 Windows 任务计划程序运行时不运行 - Excel macros run through powershell but not when run by windows task scheduler 使用任务计划程序从 PowerShell 创建电子邮件(运行时错误 429) - Create email from PowerShell using Task Scheduler (Runtime Error 429) 自动更新 Excel 文件,使用任务计划程序运行宏 - Auto Update Excel File, running Macro with Task Scheduler 任务计划程序打开 Excel 文件但继续运行且未完成 - Task Scheduler Opens Excel file but keeps running and does not complete 使用Task Scheduler在运行的Excel实例中打开Excel文件 - Open an Excel file in running instance of Excel with Task Scheduler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM