Исключение управляемого API Powershell EWS при обновлении

Я пытаюсь обновить некоторые встречи на бирже с помощью управляемого API EWS, но при вызове обновления постоянно получаю следующую ошибку:

Exception: System.Management.Automation.MethodInvocationException: Exception calling "Update" with "1" argument(s): "Set action is invalid for property." ---> Microsoft.Exchange.WebServices.Data.ServiceResponseException: Set action is invalid 
                    for property.
                       at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
                       at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalUpdateItems(IEnumerable`1 items, FolderId savedItemsDestinationFolderId, ConflictResolutionMode conflictResolution, Nullable`1 messageDisposition, Nullable`1 
                    sendInvitationsOrCancellationsMode, ServiceErrorHandling errorHandling)
                       at Microsoft.Exchange.WebServices.Data.ExchangeService.UpdateItem(Item item, FolderId savedItemsDestinationFolderId, ConflictResolutionMode conflictResolution, Nullable`1 messageDisposition, Nullable`1 
                    sendInvitationsOrCancellationsMode)
                       at Microsoft.Exchange.WebServices.Data.Item.InternalUpdate(FolderId parentFolderId, ConflictResolutionMode conflictResolutionMode, Nullable`1 messageDisposition, Nullable`1 sendInvitationsOrCancellationsMode)
                       at Microsoft.Exchange.WebServices.Data.Item.Update(ConflictResolutionMode conflictResolutionMode)
                       at CallSite.Target(Closure , CallSite , Object , Object )
                       --- End of inner exception stack trace ---
                       at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                       at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                       at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

Эта ошибка не очень описательная, поэтому я действительно не знаю, с чего начать. Все, что я пытаюсь сделать, это изменить время начала и окончания нескольких встреч. Соответствующий код приведен ниже:

$Items = $service.FindAppointments($Calendar.Id,$CalendarView)
foreach($Item in $Items.Items) {
    $Item.Load()
    $Item.StartTimeZone = [System.TimeZoneInfo]::Local
    if ($Item.Subject -eq '01Mar13 15:00 RECD-MTWRF to 30Sep13 17:00'){
        if ($Item.Start.ToString("dddd") -eq 'Friday'){
            $Item.Start = $Item.Start.AddHours(1)
        }
    }
    elseif ($Item.Subject -eq '05Mar13 10:00 RECD-TR to 26Sep13 12:00'){
        if ($Item.Start.ToString("dddd") -eq 'Tuesday'){
            $Item.Start = $Item.Start.AddHours(1)
            $Item.End = $Item.End.AddHours(1)
        }
    }
    try {
        $Item.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite)
    }
    catch {
        $error[0] | fl -force
    }
}

Я пытался изменить режим разрешения конфликтов, а также должен был установить свойство Item.StartTimeZone из-за предыдущей ошибки. Любые идеи о том, что может быть не так? Заранее спасибо.


person Nick Nicolini    schedule 08.08.2013    source источник
comment
Какое определение для $CalendarView?   -  person SliverNinja - MSFT    schedule 09.08.2013
comment
$CalendarView в основном показывает диапазон календаря для просмотра, то есть: $CalendarView = New-Object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate), где startdate и enddate — это уже определенные объекты даты и времени.   -  person Nick Nicolini    schedule 09.08.2013


Ответы (1)


Я пробовал это и отлично работает для меня:

 $Item.Update("AlwaysOverwrite")
person Patricio Iglesias    schedule 23.05.2017
comment
могу я узнать почему? - person Patricio Iglesias; 30.06.2017