1

我试图找出我们作为一个部门(约 100 人)在会议上花费了多少时间。为简单起见,我们可以将所有繁忙时间视为会议时间。但是我不知道该怎么做,我希望有人有想法

4

1 回答 1

0

整个网络上都有使用 EWS API 处理此类事情的示例。例如,您可以使用的想法:

使用 EWS 托管 API 获取约会。以下代码示例演示如何使用 EWS 托管 API 来检索位于指定开始时间和结束时间之间的用户约会。

// Initialize values for the start and end times, and the number of appointments to retrieve.
            DateTime startDate = DateTime.Now;
            DateTime endDate = startDate.AddDays(30);
            const int NUM_APPTS = 5;
            // Initialize the calendar folder object with only the folder ID. 
            CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
            // Set the start and end time and number of appointments to retrieve.
            CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);
            // Limit the properties returned to the appointment's subject, start time, and end time.
            cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
            // Retrieve a collection of appointments by using the calendar view.
            FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);
            Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() + 
                              " to " + endDate.Date.ToShortDateString() + " are: \n");
        
            foreach (Appointment a in appointments)
            {
                Console.Write("Subject: " + a.Subject.ToString() + " ");
                Console.Write("Start: " + a.Start.ToString() + " ");
                Console.Write("End: " + a.End.ToString());
                Console.WriteLine();
            }

https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-get-appointments-and-meetings-by-using-ews-in-exchange

使用 EWS 托管 API 显示日历中的约会的基本 Powershell 脚本

$MailboxName = 'SomeUserEmailALias'

$StartDate = Get-Date
$EndDate = (Get-Date).AddDays(7)

$DllPath = 'C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll'
[void][Reflection.Assembly]::LoadFile($DllPath)
$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
$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.PropertySet = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$CalendarResult = $CalendarFolder.FindAppointments($CalendarView)

foreach ($Appointment in $CalendarResult.Items)
{
    $Propset = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)

    $Appointment.load($Propset)

    New-Object -TypeName PSObject -Property @{
            Appointment = $Appointment.Subject.ToString()
            Start = $Appointment.Start.ToString()
            End = $Appointment.End.ToString()
            Organizer = $Appointment.Organizer.ToString()
        }
}

https://gsexdev.blogspot.com/2009/11/basic-powershell-script-to-show.html

[Powershell 脚本 EWS] 使用 EWS 托管 API 处理日历项目

$Folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId `

([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$MailboxToImpersonate) 
$cal=[Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$Folderid)

$StartDate =(Get-Date)

$EndDate =(get-date).AddDays(7)
$CalendarView = New-Object Microsoft.Exchange.WebServices.Data.CalendarView `
($StartDate,$EndDate,$itemsView)
$findCalItems = $service.FindAppointments($Cal.Id,$CalendarView)

param
(
    $mailbox="SomeUserEmailALias",
    $itemsView=1000,
    $userName=$cred.UserName,
    $password=$cred.GetNetworkCredential().password,
    $StartDate =(Get-Date),
    $EndDate =(get-date).AddDays(7) # find meeting upto next 7 days.
)
#set EWS URL and Web Service DLL file location path below.
$uri=[system.URI] "https://outlook.office365.com/ews/exchange.asmx"
$dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
Import-Module $dllpath

#Set Exchange Version
$ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion)
$service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials -ArgumentList $userName, $password
$service.url = $uri

$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)

#Define the calendar view
$CalendarView = New-Object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate,$itemsView)    
$findCalItems = $service.FindAppointments($Cal.Id,$CalendarView)

$report = $findCalItems | Select Start,End,Duration,AppointmentType,Subject,Location,
Organizer,DisplayTo,DisplayCC,HasAttachments,IsReminderSet,ReminderDueBy

$report | Export-Csv $($mailbox + "-Meetings.csv") -NoTypeInformation

https://www.linkedin.com/pulse/powershell-script-ews-working-calendar-items-using-managed-chauhan

用于将日历信息导出到 CSV 文件的 EWS 脚本。

.Synopsis:

Script which creates a function "Export-CalendarInformation" which can be used to export details of each calendar items to a CSV file.



. Description:

Using EWS API and authorized credentials (can use an account with application impersonation permission) this script exports below details of each calendar item in a mailbox calendar to CSV file. This script will return



StartTime, EndTime, Duration, Type, Subject, Location, Organizer, Attendees, AppointmentState, Notes, HasAttachments, IsReminderSet

https://gallery.technet.microsoft.com/EWS-Script-to-Export-c76a0ad4

于 2018-08-06T22:37:25.543 回答