我正在使用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))"
謝謝,這聽起來很有希望。我會很快研究它,並希望能夠提出一些建議,儘管這聽起來像需要一些工作。如果您好奇,我正在製作一個PowerShell腳本來刪除O365租戶中每個郵箱的垃圾郵件和惡意郵件:https://github.com/jdgregson/Delete-Emails-O365/blob/master/Delete-Emails的.ps1。到目前爲止它非常有效,但有一個問題是無法確認電子郵件已移至已刪除的郵件文件夾。 – jdgregson