Windows Server provides a special version of PowerShell for Exchange Server administration — the Exchange Management Shell. Combining it with the Windows Task Scheduler lets you automate Exchange admin tasks.
However, you can't simply create an Exchange Management PowerShell script and run it directly via Task Scheduler. You need to go through regular PowerShell as described below.
C:\Windows\System32\WindowsPowerShell1.0\powershell.exe
Under Add arguments, use the following to pass your script:
PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc1" -Command C:\Scripts\script.ps1
First, PowerShell is told to load an Exchange Server console via the path to ExShell.psc1 — an XML ConsoleFile that configures the current PowerShell session as an Exchange Management Shell. Then -Command tells it which script to run.
There's actually an easier approach these days — see: Use PowerShell ISE as Exchange Management Shell
This means your script only needs Add-PSSnapin ... as the first line to load the Exchange Management Shell.
H@ppy H@cking