3
votes

How would I access a Shared Calendar from Exchange using the EWS or the EWS managed API? I need to be able to read the items from it.

1

1 Answers

4
votes

Something to start with, maybe?

# Your mailbox here
$mailboxName = "[email protected]"

Add-Type -Path "C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll"  
$version = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2  
$service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService($version)  
$service.UseDefaultCredentials = $true  
$service.AutodiscoverUrl($mailboxName)

$folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar, $mailboxName)
$calendarFolder = [Microsoft.Exchange.WebServices.Data.calendarFolder]::Bind($service, $folderid)
$calendarView = new-object Microsoft.Exchange.WebServices.Data.CalendarView([System.DateTime]::Now, [System.DateTime]::Now.AddDays(720))
$calendarView.MaxItemsReturned = 200;
$calendarView.PropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$result = $calendarFolder.FindAppointments($calendarView)

$result | Format-Table