powershell 扫描Outlook日历条目(Powershell)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 扫描Outlook日历条目(Powershell)相关的知识,希望对你有一定的参考价值。

clear

$StartDatum = "01.01.13"
$EndDatum = "01.09.13"
$users = @{ "max müller" = @(); "peter pan" = @(); "mitz mausi" = @(); "fun farah" = @()}
$LookupCalender = "Calendar Name"


$usersKW = $users.Clone()
$outHash = $users.Clone()

Add-Type -AssemblyName Microsoft.Office.Interop.Outlook

$class = @"
using Microsoft.Office.Interop.Outlook;public class MyOL
{
    public MAPIFolder GetCalendar(string userName)
    {
        Application oOutlook = new Application();
        NameSpace oNs = oOutlook.GetNamespace("MAPI");
        Recipient oRep = oNs.CreateRecipient(userName);
        MAPIFolder calendar = oNs.GetSharedDefaultFolder(oRep, OlDefaultFolders.olFolderCalendar);
        return calendar;
    }
}
"@

Add-Type $class -ReferencedAssemblies Microsoft.Office.Interop.Outlook
$MyOL = New-Object MyOL
$olInbox = $MyOL.GetCalendar($LookupCalender)

#http://cjoprey.blog.com/2010/03/09/getting-another-users-outlook-folder/

# Get-CalendarWeek by Holger Adam
# Simple function to retrieve the calendar week to a given or the current date.

function Get-CalendarWeek 
{
 param($Date = (Get-Date))
 
 # get current culture object
 $Culture = [System.Globalization.CultureInfo]::CurrentCulture
 
 # retrieve calendar week
 $Culture.Calendar.GetWeekOfYear($Date, $Culture.DateTimeFormat.CalendarWeekRule, 
 $Culture.DateTimeFormat.FirstDayOfWeek)
} #end function Get-CalendarWeek



$olInbox.Items.Restrict("[Start] > '$StartDatum' AND [End] < '$EndDatum'") | ?{ $_.Subject -match "Appointment-Descriptions-(Pattern)-Comes-Here" } | %{	
	$tmp = $users.Clone();
	foreach($u in $users.Keys){
		if ($_.RequiredAttendees -match $u){
			$tmp[$u] += $_.Start
			$usersKW[$u] += Get-CalendarWeek( Get-Date($_.Start) )
		}
	}
	$users = $tmp
}



$users.Keys | %{
	$multipleTimesInWeek = $users[$_].count - ($usersKW[$_] | Sort-Object | Get-Unique ).Count
	if($multipleTimesInWeek -gt 1){	
		$o = ("{0} ({1} davon kommmen mehrfach in derselben Woche vor)" -f  $users[$_].count,  $multipleTimesInWeek)	
	}else{
		$o = $users[$_].count
	}
	$outHash[$_] = $o
}

# $users
$outHash.GetEnumerator() | Sort Value -Descending

以上是关于powershell 扫描Outlook日历条目(Powershell)的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 VBA 识别 MS Outlook 中的日历条目?

Outlook 支持哪些协议进行 2 向日历同步?

获取 Outlook 日历邮件

通过 API 共享 Outlook 日历

在Outlook 2019中,我在哪里可以找到Outlook日历权限?

需要建立日历(iCal、outlook)链接的服务