Most Popular Names at CSU
December 13, 2016
/Delete-all-comments Hack – Lessons Learned
January 11, 2017

Using Task Scheduler To Open Outlook At Predefined Intervals, Using PowerShell

This post is going to show you how to leverage Windows Task Scheduler and PowerShell in order to open Outlook at predefined intervals throughout the day.  Why you ask?  If you find yourself unable to ignore those pesky new message notifications (or, if you already know how to disable Outlook notifications, but can’t resist the urge to check your e-mail constantly regardless), it can be helpful to simply keep Outlook closed for most of the day in order to stay on task.  However, because we all still have to check e-mail every now and then (and in my case, once I closed Outlook in the morning, I’d forget to re-open it), you can just set things up to open Outlook automatically (eg, at 7am, 11am, and 3pm every work day).  Additionally, it’d be best to only open Outlook if it’s not already opened (otherwise, it will continue to open multiple instances of Outlook while you are out on vacation, or if you forget to close the program after you are done catching up on missed e-mails).  Anyways, here we go:

  1. First let’s create the short powershell script to open Outlook (but only if it’s not already running).  Pick a location on your computer for your script.  For this example I’m using “C:\Users\YOURUSERACCOUNT\Documents\Scripts”.  In the Scripts folder I created, I created a new text file (right click –> New –> Text Document), named it “open-outlook.txt”, then I pasted in the following text into the document:if((Get-Process -Name outlook -ErrorAction SilentlyContinue) -eq $null){
    ."C:\Program Files (x86)\Microsoft Office\Office16\OUTLOOK.EXE"
    }
  2. Obviously you should check whether Outlook is in fact located at “C:\Program Files (x86)\Microsoft Office\Office16\OUTLOOK.EXE” on your machine and update the above text accordingly.
  3. Save the document and change the file extension from .txt to .ps1 (eg, under Properties –> General you can rename the file, or just do it in Windows Explorer)
  4. Now on to the Task Scheduler to run our script.  Press the windows key and type “Task Scheduler”
  5. Under “Actions” in the right sidebar click “Create Task”
  6. Give your task a name such as “Open Outlook Automatically at 7am”
  7. Click the “Triggers” tab and click “New”
  8. Select “Weekly” then select every work day.  For a start time enter 7:00:00 AM. Hit OK
  9. Select “Actions” tab and click “New” (Action should already be set to Start a program).  Enter “powershell” (without quotes) for “Program/script”
  10.  For “Add arguments” enter the following (obviously switching out YOURUSERACCOUNT to get the correct path):-ExecutionPolicy bypass C:\Users\YOURUSERACCOUNT\Documents\Scripts\open-outlook.ps1
  11. If you want to read more about PowerShell’s execution policy, see https://technet.microsoft.com/en-us/library/ee176961.aspx. Click OK and then OK again to create the task.
  12. With the task selected, you may wish to click “Run” in order to confirm that the script is working (just be sure to close Outlook first so that you can see the script actually doing something).  If you run the script again, once Outlook is open, you can see that it won’t keep opening new instances of the program.
  13. Finally, you can optionally use the Export/Import functionality within the Task Scheduler to create additional automated tasks for other times of the day.

Obviously all of the above is pointless if you haven’t trained yourself to close Outlook once you’ve caught up on e-mails.  In any case, I hope this helps someone out.