Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 使用EWS从单个事件中删除整个会议系列_Powershell_Exchange Server_Exchangewebservices - Fatal编程技术网

Powershell 使用EWS从单个事件中删除整个会议系列

Powershell 使用EWS从单个事件中删除整个会议系列,powershell,exchange-server,exchangewebservices,Powershell,Exchange Server,Exchangewebservices,目前,我正在尝试在Exchange2007中对我的组织室日历进行一些清理。现在,我正在将去年的所有日历项导出到一个包含所有日历项的列表中 我正在搜索列表,查找名称中包含短语“已取消:”的日历项。 一旦我找到一个符合这个标准的会议,我就会对这个项目进行硬删除 这对于删除介于今天和365天前之间的已取消会议非常有效 然而,一些用户在2010年决定,他们将从现在起一直预订一次定期会议,直到时间结束。我们现在制定了一项政策,不允许提前366天以上预订,但这是一项新政策,因此旧的定期会议仍然存在 那么,当

目前,我正在尝试在Exchange2007中对我的组织室日历进行一些清理。现在,我正在将去年的所有日历项导出到一个包含所有日历项的列表中

我正在搜索列表,查找名称中包含短语“已取消:”的日历项。 一旦我找到一个符合这个标准的会议,我就会对这个项目进行硬删除

这对于删除介于今天和365天前之间的已取消会议非常有效

然而,一些用户在2010年决定,他们将从现在起一直预订一次定期会议,直到时间结束。我们现在制定了一项政策,不允许提前366天以上预订,但这是一项新政策,因此旧的定期会议仍然存在

那么,当我在过去365天内搜索到一次事件时,如何删除整个系列

可以完全绕过我的问题的一个附带问题是:

如何查询日历上的每个日历事件


在这种情况下,我可以删除每次会议,因为它将捕获我查询中的所有事件。

如果您使用日历分页扩展定期约会,则您将被限制为可以返回的最大约会次数和可以返回的时间段。在当前方法中获取主实例的最简单方法是使用BindToRecurringMaster方法,您需要做的就是向它提供其中一个实例的ItemId

否则,您可以使用带有限制的FindItem来查找没有结束日期的定期约会,并将其删除,例如

# Bind to the Calendar Folder
$folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$MailboxName)   
$Calendar = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)

$Recurring = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::Appointment, 0x8223,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Boolean); 

$sfItemSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo($Recurring,$true) 


#Define ItemView to retrive just 1000 Items    
$ivItemView =  New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)   
$rptCollection = @()
$fiItems = $null    
do{ 
    $psPropset= new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)  
    $fiItems = $service.FindItems($Calendar.Id,$sfItemSearchFilter,$ivItemView)   
    if($fiItems.Items.Count -gt 0){
        [Void]$service.LoadPropertiesForItems($fiItems,$psPropset)  
        foreach($Item in $fiItems.Items){ 
            if($Item.Recurrence.HasEnd -eq $false){
                ## Do something of place other tests to ensure you don't delete the wrong thing
            }
        }
    }
    $ivItemView.Offset += $fiItems.Items.Count    
}while($fiItems.MoreAvailable -eq $true)