Skip to content

Instantly share code, notes, and snippets.

@mdehaas
Last active July 8, 2021 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdehaas/cc6b1e94054cbdc7cbec0a4e3ca113a3 to your computer and use it in GitHub Desktop.
Save mdehaas/cc6b1e94054cbdc7cbec0a4e3ca113a3 to your computer and use it in GitHub Desktop.
Create Outlook Appointment
$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()
<#
#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