2017-08-05 138 views
1

我正在使用Office 365的安全&合规性中心执行ComplianceSearch并使用软删除删除有问题的电子邮件。完成后,我会执行相同的搜索以确认电子邮件已删除,但查看我的搜索查询的结果数量相同。这是因为软删除将电子邮件移动到“可恢复的项目”文件夹。我的问题是,如何在排除“可恢复的项目”文件夹的同时创建New-ComplianceSearch从New-ComplianceSearch中排除可恢复的项目文件夹

UPDATE 马修指出我在正确的方向下面。使用脚本here(及以下),你能得到的缺失,可恢复的项目,并清除文件夹的FolderID指定邮箱:

# Collect the target email address 
$addressOrSite = Read-Host "Enter an email address" 

# Authenticate with Exchange Online and the Security & Complaince Center (Exchange Online Protection - EOP) 
if (!$credentials) 
{ 
    $credentials = Get-Credential 
} 

if ($addressOrSite.IndexOf("@") -ige 0) 
{ 
    # List the folder Ids for the target mailbox 
    $emailAddress = $addressOrSite 

    # Authenticate with Exchange Online 
    if (!$ExoSession) 
    { 
     $ExoSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell-liveid/ -Credential $credentials -Authentication Basic -AllowRedirection 
     Import-PSSession $ExoSession -AllowClobber -DisableNameChecking 
    } 

    $folderQueries = @() 
    $folderStatistics = Get-MailboxFolderStatistics $emailAddress 
    foreach ($folderStatistic in $folderStatistics) 
    { 
     $folderId = $folderStatistic.FolderId; 
     $folderPath = $folderStatistic.FolderPath; 

     $encoding= [System.Text.Encoding]::GetEncoding("us-ascii") 
     $nibbler= $encoding.GetBytes("ABCDEF"); 
     $folderIdBytes = [Convert]::FromBase64String($folderId); 
     $indexIdBytes = New-Object byte[] 48; 
     $indexIdIdx=0; 
     $folderIdBytes | select -skip 23 -First 24 | %{$indexIdBytes[$indexIdIdx++]=$nibbler[$_ -shr 4];$indexIdBytes[$indexIdIdx++]=$nibbler[$_ -band 0xF]} 
     $folderQuery = "folderid:$($encoding.GetString($indexIdBytes))"; 

     $folderStat = New-Object PSObject 
     Add-Member -InputObject $folderStat -MemberType NoteProperty -Name FolderPath -Value $folderPath 
     Add-Member -InputObject $folderStat -MemberType NoteProperty -Name FolderQuery -Value $folderQuery 

     $folderQueries += $folderStat 
    } 
    Write-Host "-----Exchange Folders-----" 
    $folderQueries |ft 
} 

然后,您可以使用这些FolderIDs从您的搜索中删除的文件夹。例如:

New-ComplianceSearch -Name test123 -ExchangeLocation [email protected] -ContentMatchQuery "subject:'some subject' AND NOT ((folderid:3F4BE1AEF6C6BB45B8F8EEFE472A7E5C0000000001130000) OR (folderid:3F4BE1AEF6C6BB45B8F8EEFE472A7E5C0000000001140000) OR (folderid:3F4BE1AEF6C6BB45B8F8EEFE472A7E5C0000000001160000))" 

回答

1

从安全&合规中心文件夹除外的关键是FolderID财产。您可以在这个网站上找到此文档和其他属性:

https://support.office.com/en-us/article/Keyword-queries-and-search-conditions-for-Content-Search-c4639c2e-7223-4302-8e0d-b6e10f1c3be3?ui=en-US&rs=en-US&ad=US

如果您在链接搜索FolderID,你会发现如何获得FolderIDs特定邮箱的另一个链接到一个文件中,包括PowerShell代码。该链接:

https://support.office.com/en-us/article/Use-Content-Search-in-Office-365-for-targeted-collections-e3cbc79c-5e97-43d3-8371-9fbc398cd92e?ui=en-US&rs=en-US&ad=US#step1

你正在尝试做的,排除可恢复的项目,实际上涉及到不包括四个独立的文件夹:

/Recoverable Items 
/Deletions 
/Purges 
/Versions 

每个这些文件夹中都会有相关的FolderID。从上面的第二个链接作为一个例子中的值...

/Recoverable Items folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001140000 
/Deletions   folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001150000 
/Purges    folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001170000 
/Versions   folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001160000 

...您可以附加这样的事情你的关键字搜索,以排除这些文件夹:

NOT ((folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001140000) OR (folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001150000) OR (folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001170000) OR (folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001160000)) 

当然,您必须从每个您想要执行此操作的邮箱中检索这四个文件夹的实际值。还要注意,排除文件夹不会而不是排除其子文件夹...您需要为每个文件夹和每个您想要排除或包含的子文件夹使用FolderID值。

希望这会有所帮助!

+0

谢谢,这听起来很有希望。我会很快研究它,并希望能够提出一些建议,尽管这听起来像需要一些工作。如果您好奇,我正在制作一个PowerShell脚本来删除O365租户中每个邮箱的垃圾邮件和恶意邮件:https://github.com/jdgregson/Delete-Emails-O365/blob/master/Delete-Emails的.ps1。到目前为止它非常有效,但有一个问题是无法确认电子邮件已移至已删除的邮件文件夹。 – jdgregson

相关问题