【问题标题】:Issue with windows task scheduler with running a powershell script in windows 2008 server在 windows 2008 服务器中运行 powershell 脚本时 windows 任务计划程序出现问题
【发布时间】:2013-02-11 18:53:01
【问题描述】:

这个问题似乎是一个非常常见的问题,但我已经为解决方案做了所有可能的事情,但对我没有任何帮助。 我正在尝试通过批处理 powershell.exe c:\Powershell\process.ps1 运行 powershell 脚本 process.ps1 - 我的 powershell 脚本所在的位置。 我遇到了一个奇怪的问题,当我在 windows 任务计划程序中安排任务时,它显示操作已成功完成,但是当我检查结果时,什么也没发生。 "脚本根本没有运行"

当我手动双击批处理时,脚本运行得非常好。我的问题是,当脚本手动批量运行良好时,未在任务调度程序中运行的原因可能是什么。从技术上讲...脚本在 cmd.exe 中运行,但未按计划运行(Windows 任务调度程序 2008 服务器)。

我尝试检查 Windows 任务调度程序中的每一个选项,我从多年前就开始使用任务调度程序。我完全无法理解进一步的故障排除步骤。请帮助

【问题讨论】:

  • 补充一下我的问题,我的服务器上安装了powershellv1.0。

标签: batch-file powershell scheduled-tasks batch-processing powershell-1.0


【解决方案1】:

这有用吗? 创建计划任务以运行 PowerShell 脚本
http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx

总结:在“启动程序”窗格的“程序/脚本”框中
powershell -file "path\and\script\filename.ps1"

【讨论】:

  • 我刚刚浏览了链接,看起来我有一个解决方案。我现在到家了。我会运行它并让您知道结果..感谢您的回复。顺便说一句..我正在使用 powershell 脚本: $DateToDelete = 1 $StartFolder = "\\Network UNC path" dir $StartFolder -Recurse -Force -ea 0 | ?{!$_.PsIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-$DateToDelete)} | del -Force,我希望它的功能不会有任何问题。
猜你喜欢
  • 1970-01-01
  • 2013-08-22
  • 2010-12-27
  • 1970-01-01
  • 1970-01-01
  • 2019-05-08
  • 2018-04-04
  • 2013-02-18
  • 1970-01-01
相关资源
最近更新 更多