【发布时间】:2015-05-28 12:00:11
【问题描述】:
我是早期的 Exchange Server 管理员,我想开始使用任务计划程序来调用位于我的 C:\ 驱动器中的 Powershell 脚本。
我希望帮助我运行以下名为 Script A 的 Powershell 脚本,该脚本位于 C:\Scripts\Script A Folder\Script A.PS1
我还需要将参数-Reportonly 附加到shell 脚本的末尾。我目前正在使用以下内容:
程序/脚本
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
添加参数
-version 2.0 -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; - File "C:\Scripts\TScript A Folder\Script A.ps1"
我需要运行一个批处理文件还是没有这个可以工作?
我不能让它为爱或金钱工作。任何帮助将不胜感激
【问题讨论】:
-
从 powershell / cmd 直接调用时,你能让脚本 A 工作吗?这就是你需要做的。当你有这个工作时,把它放在任务计划程序中,并确保它由适当的用户运行
-
我认为您不应该将
-Command和-File与 PowerShell 混合使用。如果它确实有效,我不知道哪个会先执行。滚动到脚本 A.ps1 并从那里调用它。 -
-Command参数的参数缺少右双引号。您究竟希望- File "C:\Scripts\TScript A Folder\Script A.ps1"做什么?你明白你已经把它嵌入到你的-Command参数中,对吧?你的意思是&'C:\Scripts\TScript A Folder\Script A.ps1'? -
- file不应该有空格,或者错过评论窗口,并且没有意义 ;在它之前。使用arco的评论。在本地测试它。你会得到这些错误来帮助你调试
标签: powershell batch-file scheduled-tasks