mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-31 19:26:27 +02:00
Add open-microsoft-outlook.ps1 and close-microsoft-outlook.ps1
This commit is contained in:
parent
2386fa4df9
commit
9d240326c8
15
Scripts/close-microsoft-outlook.ps1
Normal file
15
Scripts/close-microsoft-outlook.ps1
Normal file
@ -0,0 +1,15 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Closes Microsoft Outlook
|
||||
.DESCRIPTION
|
||||
This script closes the Microsoft Outlook email application gracefully.
|
||||
.EXAMPLE
|
||||
PS> ./close-microsoft-outlook
|
||||
.NOTES
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
taskkill /im outlook.exe
|
||||
exit 0 # success
|
28
Scripts/open-microsoft-outlook.ps1
Normal file
28
Scripts/open-microsoft-outlook.ps1
Normal file
@ -0,0 +1,28 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Launches Microsoft Outlook
|
||||
.DESCRIPTION
|
||||
This script launches the Microsoft Outlook email application.
|
||||
.EXAMPLE
|
||||
PS> ./open-microsoft-outlook
|
||||
.NOTES
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
function TryLaunching { param($Path)
|
||||
if (test-path "$Path" -pathType leaf) {
|
||||
start-process "$Path"
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
TryLaunching "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"
|
||||
TryLaunching "C:\Programs\Microsoft Office\Office14\OUTLOOK.EXE"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user