Hi, so you have downloaded one of my Exchange PowerShell script, and you liked it ( i hope) , so now you want to schedule the script to run in a schedule that you like.
SO EASY 🙂 Follow my steps :
1. Open the Task Scheduler in Windows > Task Scheduler Library >right click and “Create Basic Task..”
2. Type a descriptive name for your task and click Next.
3. On the Trigger section, choose your schedule that fits your needs.
4. On the Action, choose “Start a program” ,Click Next.
5. On the “Start a Program” subsection, Enter:
- In the Program/Script, type (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)
- In the Add Arguments (Optional) ,type (-command “. ‘c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto; D:\Myscript.PS1)
- In the Start in (Optional), leave it empty
Note : Replace D:\Myscript.PS1 with your script path.
Note: Make sure the machine has Exchange PowerShell Management Tools
Be careful !!!!!!!!!!
I have discovered in a hard way, that you will get problem and the script will not run if the path length to your script is too long. For example, it is not good idea instead of D:\Myscript.PS1, to have D:\Path1\path2\path3\path3 management scripts for Exchange that i love to schedule\Script Directory\Cool Scripts\Myscript.PS1
This is a long path, and there is a limit for the length of commands in the Windows Task Scheduler. Keep that in mind.