Search code examples
powershellwindows-task-scheduler

Opening specific Outlook profile with Powershell


When I run the simple script in PowerShell to open Outlook it works, but when I want to run it via the Task Scheduler it doesn't work.

Script used:

Start-Process -FilePath "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"

I think the problem is that I login with one account and my Outlook profile is from a different account. I tried to change the User or Group inside the Task Scheduler, but this also gives me an error that the account is not found.

How can I setup my PowerShell script to ensure I open Outlook with the correct profile?


Solution

  • $ProfileName = "Whatever"
    
    Start-Process -FilePath "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" -ArgumentList "/profile `"$ProfileName`""
    

    This might work?