2017-08-05 183 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

相關問題