Skip to content

Instantly share code, notes, and snippets.

@swbuehler
Created March 13, 2017 16:08
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 swbuehler/a26f01e69613549a334578ac193dc5ce to your computer and use it in GitHub Desktop.
Save swbuehler/a26f01e69613549a334578ac193dc5ce to your computer and use it in GitHub Desktop.
PowerShell - Retrieves and displays daily Outlook appointments.
$olFolderCalendar = 9
$ol = New-Object -ComObject Outlook.Application
$ns = $ol.GetNamespace('MAPI')
$Start = (Get-Date).AddDays(-1).ToShortDateString() + " 00:00"
$End = (Get-Date).AddDays(+1).ToShortDateString() + " 00:00"
$Filter = "[MessageClass]='IPM.Appointment' AND [Start] >= '$Start' AND [End] <= '$End'"
$Appointments = $ns.GetDefaultFolder($olFolderCalendar).Items
$Appointments.IncludeRecurrences = $true
$Appointments.Sort("[Start]")
foreach ($Appointment in $Appointments.Restrict($Filter) ) {
$Appointment | Select-Object -Property Start, Subject, Location
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment