(一)針對於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"
參考資料
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小站微信公衆號