I've found lots of great scripts to open a program if it isn't running, but Outlook is proving to be tricky. In Windows 10 (build 170121) it opens and runs in the background on login, so Get-Process will always find at least one instance whether the application is open from a user perspective (opens a second process). My uneducated guess is that it's always there because I set Outlook as my default mail program in Win 10 settings.
I can see unique attributes of the background process like the PID is lower and the number of User Objects = 1, but there has to be a way to definitively test if the UI is open (what I'm calling the second process and want to test for)
This is a script that works well for programs that aren't always running in the background. Would someone be kind enough to help point me to a definitive test for the UI process? Many thanks in advance!
if((Get-Process -Name OUTLOOK -ErrorAction SilentlyContinue) -eq $null){
."C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"
}