Powershell 添加startTimeZone和endTimeZone

Powershell 添加startTimeZone和endTimeZone,powershell,Powershell,为什么我不能为我的预约设定时区 try { $Appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service); $Appointment.Subject=$CalendarItem."Subject"; $Appointment.Start=$calendarItem."StartDateTime"; $Appointment.End=$calendarItem.

为什么我不能为我的预约设定时区

try
{
    $Appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service);
    $Appointment.Subject=$CalendarItem."Subject";
    $Appointment.Start=$calendarItem."StartDateTime";
    $Appointment.End=$calendarItem."EndDateTime";
    $Appointment.Resources.Add($CalendarItem."Resources");
    $Appointment.StartTimeZone="Tokyo Standard Time";
}
catch
{
    # If we fail to set any of the required fields, we will not write the appointment
    $NoError=$false;
}

下面介绍如何在创建ExchangeService对象后进行指定

try
{
    $Appointment = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service);
    $Appointment.Subject=$CalendarItem."Subject";
    $Appointment.Start=$calendarItem."StartDateTime";
    $Appointment.End=$calendarItem."EndDateTime";
    $Appointment.Resources.Add($CalendarItem."Resources");
    $Appointment.StartTimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Tokyo Standard Time");
}
catch
{
    # If we fail to set any of the required fields, we will not write the appointment
    $NoError=$false;
}
见:

在实例化时指定非本地时区 将用于创建日历项的ExchangeService对象, 并且不要在上设置StartTimeZone属性和EndTimeZone属性 日历项

设置日历项的StartTimeZone属性和EndTimeZone属性


嗨,谢谢你的回复。我仍然无法添加预约。我在用O365。我想你是在保存约会吧<代码>$Appointment.Save()是。如果没有错误,将执行此命令$约会.保存([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::日历);为什么你不能添加?有错误吗?保存后会发生什么?我无权访问O365,因此现在无法提供帮助。无法将startTimeZone设置到日历中。