【问题标题】:How to get outlook recurring meeting items in powershell如何在 Powershell 中获取 Outlook 定期会议项目
【发布时间】:2021-01-01 04:43:24
【问题描述】:

我正在使用下面的脚本来提取 Outlook 日历项目,它适用于发生一次的事件。重复会议邀请失败,因为它的开始日期是发送邀请的时间,而不是发生的开始时间。此外,我没有看到任何引用事件结束日期的变量,因此无法动态查找事件。关于如何获得它的任何建议?

Function Get-OutlookCalendar {
     Add-type -assembly “Microsoft.Office.Interop.Outlook” | out-null
     $olFolders = “Microsoft.Office.Interop.Outlook.OlDefaultFolders” -as [type]
     $outlook = new-object -comobject outlook.application
     $namespace = $outlook.GetNameSpace(“MAPI”)
     $folder = $namespace.getDefaultFolder($olFolders::olFolderCalendar)
     $folder.items |
     Select-Object -Property start,RequiredAttendees, Subject, IsRecurring, Organizer,ConversationID,RecurrenceState,OptionalAttendees,Body
} 
$start_date=(Get-date).AddDays(-2) |Get-Date -Format 'MM/dd/yyyy'
$end_date=Get-Date -Format 'MM/dd/yyyy'
Get-OutlookCalendar| where-object { $_.start -gt [datetime]$start_date -and $_.start -le [datetime]$end_date } | sort-object start

【问题讨论】:

  • 所以我是对的?我没有机会再次检查。
  • 是的,Doug,代码正在寻找第一个开始日期,而不是重复开始日期。有关如何解决该问题的任何建议?
  • 还没有,但我会告诉你的。

标签: powershell outlook


【解决方案1】:

你可以试试下面的开关:

switch ($item.IsRecurring)
{
    $false {
        if ($item.start -ge $dt -and $item.start -lt ($dt).AddDays(1))
        {
            $item | Select-Object -Property Subject, Start, Duration, Location, RequiredAttendees
        }
    }

    $true {
        try {
            $rec=$item.GetRecurrencePattern()
            $recitem=$rec.GetOccurrence($dt.ToString("yyyy-MM-dd") + " " + $item.Start.ToString("HH:mm"))
            $recitem | Select-Object -Property Subject, Start, Duration, Location, RequiredAttendees, IsRecurring
        }
        catch {}
        finally {}

    }
}

【讨论】:

    猜你喜欢
    • 2011-12-24
    • 1970-01-01
    • 1970-01-01
    • 2016-09-25
    • 2017-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多