繁体   English   中英

更新时Powershell EWS托管API异常

[英]Powershell EWS Managed API Exception on Update

我正在尝试使用EWS托管API在交换时更新一些约会,但是在调用update时,我不断收到以下错误消息:

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属性。 有什么想法可能有问题吗? 提前致谢。

我已经尝试过了,对我来说效果很好:

 $Item.Update("AlwaysOverwrite")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM