Closing Outlook via a (scheduled) PowerShell script - HowTo-Outlook

PHOTO EMBED

Mon Nov 20 2023 11:41:41 GMT+0000 (Coordinated Universal Time)

Saved by @paulbarry

$outlook = Get-Process outlook -ErrorAction SilentlyContinue
if ($outlook) {
	$olApp = New-Object -ComObject Outlook.Application
	$olApp.Quit()
	Remove-Variable olApp
	
	Sleep 15

	if (!$outlook.HasExited) {
		$outlook | Stop-Process -Force
		}
	}
Remove-Variable outlook
content_copyCOPY

https://www.howto-outlook.com/howto/closeoutlookscript.htm