-
Notifications
You must be signed in to change notification settings - Fork 8
/
Start-Outlook.ps1
61 lines (45 loc) · 1.53 KB
/
Start-Outlook.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function Start-Outlook {
<#
.SYNOPSIS
OutlookConnector function: Starts MS Outlook GUI. Used in case of issues with Connect-Outlook function.
.DESCRIPTION
Starts MS Outlook GUI. Used in case of issues with Connect-Outlook function.
Issues usually occure due to slow or interactive Outlook start. If GUI starts successfully, Connect-Outlook should run without issues.
Outlook executable is found via Registry search.
.INPUTS
This function is not accepting any parameters.
.OUTPUTS
Function returns nothing.
.EXAMPLE
Start-Outlook
Opens MS Outlook GUI.
.LINK
about_OutlookConnector
.NOTES
NAME: Start-Outlook
AUTHOR: Igor Iric, iricigor@gmail.com
CREATEDATE: September 29, 2015
#>
# ---------------------- [Parameters definitions] ------------------------
[CmdletBinding()]
Param ()
# ------------------------- [Function start] -----------------------------
if (Get-Process | Where-Object name -eq outlook) {
Write-Verbose -Message 'Outlook already running. No action needed.'
}
else {
$key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE\'
if (!(Test-Path -Path $key)) {
throw 'Path to Outlook executable not found.'
} else {
$exe = (Get-ItemProperty -Path $key).'(default)'
if (Test-Path -Path $exe) {
Write-Verbose -Message 'Starting Outlook application...'
Invoke-Item -Path $exe
} else {
throw 'Outlook executable not found.'
}
}
}
# ------------------------- [End of function] ----------------------------
}