✨ Important 2026 Update — Exporting Calendar Items (Graph API vs. Legacy EWS)
- Exchange Online (Use Microsoft Graph): Basic Auth EWS (
WebCredentials) andApplicationImpersonationare retired in Exchange Online, and EWS itself is being retired. UseGet-MgUserCalendarView(Calendars.Read) in Microsoft Graph PowerShell instead. - Date-Range Expansion: Both Graph's
calendarViewand EWS'sCalendarViewexpand recurring meeting series into individual occurrences within yourStartDateTime/EndDateTimewindow. - On-Premises Exchange Only: The legacy EWS Managed API 2.2 script is preserved below for on-premises Exchange Server 2016/2019/SE environments.
Exporting a user's upcoming meetings or auditing room calendar bookings via PowerShell used to require loading Microsoft.Exchange.WebServices.dll (EWS Managed API 2.2) with ApplicationImpersonation.
In Exchange Online (Microsoft 365), Microsoft Graph PowerShell (Get-MgUserCalendarView) is the modern, supported replacement—requiring zero local DLLs and supporting Certificate-Based App-Only Auth with least-privilege Calendars.Read permissions.
Method 1: Export Calendar Items via Microsoft Graph PowerShell (Exchange Online — Recommended)
POWERSHELL
# Connect to Microsoft Graph (Interactive or Certificate-Based App-Only Auth)
Connect-MgGraph -Scopes "Calendars.Read" -NoWelcome
$Mailbox = "[email protected]"
$StartDate = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$EndDate = (Get-Date).AddDays(7).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
# Fetch expanded calendar occurrences for the next 7 days
$Events = Get-MgUserCalendarView -UserId $Mailbox -StartDateTime $StartDate -EndDateTime $EndDate -All
$Report = foreach ($Ev in $Events) {
[PSCustomObject]@{
Subject = $Ev.Subject
StartUtc = $Ev.Start.DateTime
EndUtc = $Ev.End.DateTime
Organizer = $Ev.Organizer.EmailAddress.Address
Location = $Ev.Location.DisplayName
IsOnline = $Ev.IsOnlineMeeting
Type = $Ev.Type
HasAttachments = $Ev.HasAttachments
}
}
$Report | Format-Table -AutoSize
$Report | Export-Csv -Path ".\$($Mailbox -replace '@.*','')-Meetings.csv" -NoTypeInformation -Encoding UTF8
Need to audit remaining EWS apps before Exchange Online blocks EWS? Read our Audit & Block Legacy EWS Traffic in Exchange Online Guide.
Method 2: Legacy On-Premises Exchange Script (EWS Managed API 2.2)
For on-premises Exchange Server environments where EWS Managed API 2.2 and ApplicationImpersonation are still used:
POWERSHELL
param (
[string]$Mailbox = "[email protected]",
[int]$ItemsView = 1000,
[pscredential]$Credential = (Get-Credential),
[datetime]$StartDate = (Get-Date),
[datetime]$EndDate = (Get-Date).AddDays(7),
[string]$EwsUrl = "https://mail.corp.local/ews/exchange.asmx"
)
$DllPath = "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
Import-Module $DllPath
$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1)
$Service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials($Credential.UserName, $Credential.GetNetworkCredential().Password)
$Service.Url = [System.URI]$EwsUrl
$Service.ImpersonatedUserId = New-Object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SMTPAddress, $Mailbox)
$FolderId = New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar, $Mailbox)
$Cal = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service, $FolderId)
$CalendarView = New-Object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate, $EndDate, $ItemsView)
$FindCalItems = $Service.FindAppointments($Cal.Id, $CalendarView)
$FindCalItems |
Select-Object Start, End, Duration, AppointmentType, Subject, Location, Organizer, DisplayTo, DisplayCC, HasAttachments |
Export-Csv -Path ".\$($Mailbox -replace '@.*','')-Meetings.csv" -NoTypeInformation -Encoding UTF8
💬 Reader Comments & Feedback
Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.
Leave a Comment or Report an Update