Skip to main content

Get calendar entries via PowerShell

Requirements: Basic PowerShell knowhow and Outlook Application.

This documentation shows how to read calendar data from an Outlook attached mailbox in PowerShell.

Use case

This Outlook API can be used to migrate or evaluate the calendar data inside of an Outlook mapped mailbox. This data can be valuable, for example, when time evaluations should be made using the calendar.

Custom calendar entries

This PowerShell code gets all entries from a new custom calendar of the users mailbox.

$UPN = "<upnofmailboxuser>"
$Calendarname = "<calendarname>"
$ol = New-Object -comobject Outlook.Application
$ns = $ol.GetNamespace('MAPI')
$folder = $ns.Folders.Item("$UPN").Folders.Item('Calendar').Folders.Item($Calendarname)
$AllItems = $folder.items |  Select-Object -Property Subject, Start, Duration

Default calendar entries

This PowerShell code gets all entries from the default calendar of the users mailbox.

$UPN = "<upnofmailboxuser>"
$Calendarname = "<calendarname>"
$ol = New-Object -comobject Outlook.Application
$ns = $ol.GetNamespace('MAPI')
$folder = $ns.Folders.Item("$UPN").Folders.Item('Calendar')
$AllItems = $folder.items |  Select-Object -Property Subject, Start, Duration