我正在使用Office 365的安全与合规中心预置一个ComplianceSearch,并使用软删除删除违规电子邮件。一旦完成,我就预先设置相同的搜索以确认电子邮件已被删除,但对于我的搜索查询却看到相同数量的结果。这是因为软删除将电子邮件移动到可恢复项文件夹。我的问题是,如何在排除可恢复项文件夹的同时创建New-ComplianceSearch
?
更新马修给我指明了正确的方向。使用脚本这里 (和下面的脚本),您可以获得指定邮箱的删除、可恢复项和清除文件夹的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("0123456789ABCDEF");
$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
}
然后,可以使用这些FolderID从搜索中删除文件夹。例如:
New-ComplianceSearch -Name test123 -ExchangeLocation user@mycompany.com -ContentMatchQuery "subject:'some subject' AND NOT ((folderid:3F4BE1AEF6C6BB45B8F8EEFE472A7E5C0000000001130000) OR (folderid:3F4BE1AEF6C6BB45B8F8EEFE472A7E5C0000000001140000) OR (folderid:3F4BE1AEF6C6BB45B8F8EEFE472A7E5C0000000001160000))"
发布于 2017-08-23 17:47:03
将文件夹从安全性和遵从性中心排除在外的关键是FolderID属性。您可以在此站点找到有关此属性和其他属性的文档:
如果在该链接中搜索FolderID,则会发现另一个链接,该链接指向关于如何获取特定邮箱的FolderID的文档的另一个链接,包括用于此操作的PowerShell代码。这种联系是:
您要做的事情,不包括可恢复项,实际上包括排除四个单独的文件夹:
/Recoverable Items
/Deletions
/Purges
/Versions
这些文件夹中的每一个都有一个关联的FolderID。以上面第二个链接中的值为例.
/Recoverable Items folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001140000
/Deletions folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001150000
/Purges folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001170000
/Versions folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001160000
...you可以将类似的内容添加到关键字搜索中,以排除这些文件夹:
NOT ((folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001140000) OR (folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001150000) OR (folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001170000) OR (folderid:FDB58AF45BAF2F4A8CFD98F5396C6EB0000000001160000))
当然,您必须从每个要这样做的邮箱中检索这四个文件夹的实际值。还要注意的是,排除一个文件夹会使而不是排除它的subfolders...you,它需要对每个文件夹和每个要排除或包含的子文件夹使用FolderID值。
希望这能有所帮助!
https://stackoverflow.com/questions/45520444
复制相似问题