Configuration Steps .com



How to use Task Scheduler for Exchange scriptsConfiguration StepsOften times as an Exchange Administrator, there are opportunities to automate tasks. However, getting Exchange related scripts to successfully launch from Task Scheduler can prove challenging. This article will help navigate the typical hurdles involved.First test your script or Exchange commands from the Exchange Management Console. If it can't run there, it will certainly fail as a scheduled task.In Task Scheduler create a Basic TaskChoose a schedule. Choose “Start a program” as the ActionAdd the following syntax to add for the Program/script text entry box.C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeVerification of the Powershell path can be made by selecting the Browse button. This is the default path however for Powershell v1 - v4.Add the following syntax, depending on the version of the Exchange Server to schedule the task on in the "Add arguments" text box.Here’s the example for Exchange 2010 -version 2.0 -NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; <Your Script>"If I’m running the Get-EASlogs_scheduled.ps1 script from my scripts folder, the full arguments section needs the following syntax:-version 2.0 -NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; .'E:\Program Files\Microsoft\Exchange Server\V14\scripts\Get-EASlogs_scheduled.ps1'"Here's the example for Exchange 2013-NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; <Your Script>"You'll need to substitute the path to the Exchange Server installation directory if you've changed if from the defaults, and replace <Your Script> with the path and name of the Exchange Management Shell script or the Exchange commands to schedule.At the finish of the Basic Task Wizard, select the option to “Open the Properties dialog for this task when I click Finish” to configure some advanced configuration needed.At the general tab, specify "Run whether user is logged on or not" (this is critical for RBAC) and "Run with the highest privileges" (this is necessary for User Account Control)(Optional) If you need the script to run more frequently than daily, simply create multiple daily triggers varying the start time.Saving the Task will prompt for credentials. Be sure to use an account with the necessary RBAC role to run the Exchange commandlets or the script. For security purposes, use the least privileged account / role that is able to launch the script or commands manually from the server the task is scheduled on. Consider scheduling the task to run from a workstation that has the Exchange Management Shell tools installed to prevent local administrator access on the Exchange servers. For more information see the Exchange Team blog on "Protecting Against Rogue Administrators" Troubleshooting and verificationIf the commands or script have already been verified from the Exchange Management Shell, the next step is to verify the commands or script can run from the RemoteExchange.ps1 environment using an elevated command prompt. Here's an example for an Exchange 2013 command where Exchange is installed in the default location on C: and the output is piped to a local file.C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -noExit -Command ".'C:\Program Files\Microsoft\Exchange Server\V15\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Get-queue > c:\temp\queue.txt"Here's an example for an Exchange 2010 script with Exchange installed on E:C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -noExit -Command ".'E:\Program Files\Microsoft\Exchange Server\V14\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; .'E:\Program Files\Microsoft\Exchange Server\V14\scripts\CollectOverMetrics.ps1' -DatabaseAvailabilityGroup RedDag1"The Scheduled Task can then be verified further by right-clicking the task and choosing Run:Additional troubleshooting can be found in the crimson channel logging. You can access this directly from the event log, or check the history tab of the scheduled task.Microsoft-Windows-TaskScheduler/OperationalIt’s a good idea to use scripts that have their own error logging. If the task scheduler reports a result code of 0, that means the task ran successfully. However, if the expected result of the script wasn’t realized, there isn’t a way to tell what went wrong without error logging initiated from the script.Depending on how the script captures error logging, you may see errors related to running Exchange’s RemoteExchange.ps1 right369570Get-ItemProperty : Cannot find path 'HKLM:\Software\microsoft\ExchangeServer\v14\CentralAdmin' because it does not exist.At C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:107 char:21+ if (Get-ItemProperty <<<< HKLM:\Software\microsoft\ExchangeServer\v14\CentralAdmin -ea silentlycontinue) + CategoryInfo : ObjectNotFound: (HKLM:\Software\...14\CentralAdmin:String) [Get-ItemProperty], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.mands.GetItemPropertyCommand00Get-ItemProperty : Cannot find path 'HKLM:\Software\microsoft\ExchangeServer\v14\CentralAdmin' because it does not exist.At C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:107 char:21+ if (Get-ItemProperty <<<< HKLM:\Software\microsoft\ExchangeServer\v14\CentralAdmin -ea silentlycontinue) + CategoryInfo : ObjectNotFound: (HKLM:\Software\...14\CentralAdmin:String) [Get-ItemProperty], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.mands.GetItemPropertyCommandThe following error is expected since the CentralAdmin toolset is only used by Office 365.Check out “Behind the Curtain: How we run Exchange Online” for clues about this internal Central Admin tool (starting slide 27).AcknowledgementsMuch of this content was taken from Steve Goodman’s blog post on ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download