(一)针对于exchange 2010版本


首先在计划任务管理界面的启动程序里面输入

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

添加参数(可选)里面输入

-NonInteractive -WindowStyle Hidden -command ". 'D:\Program Files\MicrosoftExchange\Server\V14\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto;D:\scripts\01checkqueue.ps1"


clip_image002

参考资料

Creating Scheduled Tasks for Exchange 2010 PowerShell Scripts  http://mikepfeiffer.net/2010/02/creating-scheduled-tasks-for-exchange-2010-powershell-scripts/

How to use Task Scheduler for Exchange scripts - TechNet Articles - United States (English) - TechNet Wiki  http://social.technet.microsoft.com/wiki/contents/articles/23150.how-to-use-task-scheduler-for-exchange-scripts.aspx

注意:如果选项里面指定了remoteexchange.ps1脚本,则脚本的正文中不要再使用add-pssnapin *exchange*去导入exchange的管理模块,会导致计划任务无法停止,无法循环。


(二)针对于exchange 2013


如果脚本里面没有加载exchange的管理单元,则可以使用:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
-noExit -WindowStyle Hidden -command ". 'D:\Microsoft\Exchange Server\V15\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto;D:\scripts\统计邮件收发.ps1"

注意:如果脚本里面已经加载了exchange的管理单元,则参数中不要再添加remoteexchange.ps1,直接按照下面的格式写入即可

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noninteractive -command;D:\scripts\检查邮件队列.ps1"

欢迎关注下方MVP小站微信公众号

qrcode_for_gh_7159fb337d37_258.jpg