如何使用EWS或EWS托管API从Exchange访问共享日历?我需要能够从中读取项目。
答案 0 :(得分:3)
开始时可能会有什么?
# Your mailbox here
$mailboxName = "blah@blih.com"
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