Last active
July 8, 2021 07:01
-
-
Save mdehaas/cc6b1e94054cbdc7cbec0a4e3ca113a3 to your computer and use it in GitHub Desktop.
Create Outlook Appointment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$outlook = new-object -com Outlook.Application | |
$calendar = $outlook.Session.GetDefaultFolder(9) # == olFolderCalendar | |
$appt = $calendar.Items.Add(1) # == olAppointmentItem | |
$appt.Start = [datetime]$AppointmentTime | |
$appt.Subject = $subject | |
$appt.Location = $location | |
$appt.ReminderSet = $true | |
$appt.ReminderMinutesBeforeStart =$ReminderMinutesBeforeStart | |
$appt.Save() | |
$outlook.Quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
#Check whether Outlook is installed | |
if (-not (Test-Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE")) { | |
Write-Warning "Outlook is not installed. You need to install Outlook 2010 or later to use this Script." | |
break | |
} | |
#Check if Outlook is running. | |
$OutlookState = Get-Process | Where-Object {$_.Name -eq "outlook"} | |
if ($OutlookState) { | |
Write-Warning "Outlook is running. Please close outlook to run this script" | |
break | |
} | |
#> | |
$outlook = new-object -com Outlook.Application | |
$calendar = $outlook.Session.GetDefaultFolder(9) # == olFolderCalendar | |
$appt = $calendar.Items.Add(1) # == olAppointmentItem | |
$appt.Start = [datetime]::Today.Adddays(1).AddHours(10) | |
$appt.Subject = 'EMEA Security Update Webcast' | |
$appt.Location = 'Teams Live Event' | |
$appt.Body = "https://aka.ms/EMEAWebcast`nhttps://aka.ms/EMEA" | |
$appt.Duration = 50 | |
$appt.ReminderSet = $true | |
$appt.ReminderMinutesBeforeStart = 30 | |
$appt.Importance = 1 | |
$appt.Categories = "Security" | |
$appt.Save() | |
#$outlook.Quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment